# ElementRef

Version: 0.5.0
Framework commit: d503df2befa756e681fcdc6250e9552dc7388bea
Canonical URL: /docs/0.5.0/api/ferroui-base/struct-elementref/

**struct** · [`ferroui-base`](/docs/0.5.0/api/ferroui-base/) · v0.5.0

```rust
struct ElementRef<T: ObjectType>
```

A reference to an element that the holder does not own: the value type
of properties such as a placement target, the target of a label or the
element an adorner adorns.

Such a property points sideways or up the tree — often at an ancestor of
the element it is set on — so holding the element strongly would make
the two keep each other alive. An `ElementRef` holds it weakly and
compares by identity. Classes expose these properties with getters that
return `Option<Ref<T>>` and setters that take `impl Into<Nullable<T>>`;
untyped access and bindings convert to and from `Ref<T>` (see
`ValueTypes::register_element_ref`).

When the referenced element is dropped the reference reads as nothing;
no change notification is raised for that.

[View source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/element_ref.rs#L18)

## Members

- [`new`](#function-new)
- [`of`](#function-of)
- [`from_nullable`](#function-from_nullable)
- [`get`](#function-get)
- [`resolve`](#function-resolve)
- [`points_to`](#function-points_to)

<a id="function-new"></a>

### new

```rust
fn new<U: ObjectType + Upcast<T>>(element: &Ref<U>) -> Self
```

Creates a reference to `element`.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/element_ref.rs#L23)

<a id="function-of"></a>

### of

```rust
fn of(element: &Ref<T>) -> Self
```

Creates a reference to an element of exactly class `T`.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/element_ref.rs#L29)

<a id="function-from_nullable"></a>

### from_nullable

```rust
fn from_nullable(element: Option<Ref<T>>) -> Option<Self>
```

The property value for an optional element.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/element_ref.rs#L35)

<a id="function-get"></a>

### get

```rust
fn get(self: &Self) -> Option<Ref<T>>
```

The referenced element, if it is still alive.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/element_ref.rs#L41)

<a id="function-resolve"></a>

### resolve

```rust
fn resolve(value: &Option<Self>) -> Option<Ref<T>>
```

The element referenced by a property value.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/element_ref.rs#L47)

<a id="function-points_to"></a>

### points_to

```rust
fn points_to<U: ObjectType>(self: &Self, element: &Ref<U>) -> bool
```

Whether the reference points at `element`.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/element_ref.rs#L53)

## Trait implementations

- `Send`
- `Sync`
- `Freeze`
- `UnsafeUnpin`
- `Unpin`
- `UnwindSafe`
- `RefUnwindSafe`
- [`PropertyValue`](/docs/0.5.0/api/ferroui-base/trait-propertyvalue/)
- [`AnyValue`](/docs/0.5.0/api/ferroui-base/trait-anyvalue/)
- [`ClassDefaults`](/docs/0.5.0/api/ferroui-base/trait-classdefaults/)
- `Borrow<T>`
- `BorrowMut<T>`
- `CloneToUninit`
- `Into<U>`
- `From<T>`
- `TryInto<U>`
- `TryFrom<U>`
- `Any`
- `ToOwned`
- `ErasedDestructor`
- `IntoEither`
- `Clone`
- `PartialEq`
- `Debug`
- `From<&Ref<T>>`

## Availability

Extracted for `aarch64-apple-darwin`. Cargo features are listed in the [crate index](/docs/0.5.0/api/).
