# Ref

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

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

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

A strong reference to an object of class `T` or a class derived from it.

Cloning the handle shares the object. Equality and hashing are by object
identity.

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

## Members

- [`upcast`](#function-upcast)
- [`upcast_ref`](#function-upcast_ref)
- [`cast`](#function-cast)
- [`downcast`](#function-downcast)
- [`is`](#function-is)
- [`downgrade`](#function-downgrade)
- [`ptr_eq`](#function-ptr_eq)

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

### upcast

```rust
fn upcast<U: ObjectType>(self: Self) -> Ref<U>
where T: Upcast<U>
```

Converts the handle to a handle of a base class.

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

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

### upcast_ref

```rust
fn upcast_ref<U: ObjectType>(self: &Self) -> &Ref<U>
where T: Upcast<U>
```

Borrows the handle as a handle of a base class, without a copy of the
handle (the borrowing form of `upcast`).

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

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

### cast

```rust
fn cast<U: ObjectType>(self: &Self) -> Option<Ref<U>>
```

Returns a handle of class `U` if the object is a `U`.

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

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

### downcast

```rust
fn downcast<U: ObjectType>(self: Self) -> Result<Ref<U>, Self>
```

Converts the handle to class `U` if the object is a `U`, otherwise
returns the handle unchanged.

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

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

### is

```rust
fn is<U: ObjectType>(self: &Self) -> bool
```

Whether the object is of class `U` or a class derived from it.

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

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

### downgrade

```rust
fn downgrade(self: &Self) -> WeakRef<T>
```

Creates a weak reference to the object.

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

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

### ptr_eq

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

Whether two handles refer to the same object.

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

## Trait implementations

- `Send`
- `Sync`
- `Freeze`
- `UnsafeUnpin`
- `Unpin`
- `UnwindSafe`
- `RefUnwindSafe`
- [`ResourceKeyObject`](/docs/0.5.0/api/ferroui-base/controls/trait-resourcekeyobject/)
- [`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>`
- [`Receiver`](/docs/0.5.0/api/ferroui-system/task/oneshot/struct-receiver/)
- `Any`
- `ToOwned`
- `ErasedDestructor`
- `IntoEither`
- `From<Ref<Animation>>`
- `From<&Ref<Animation>>`
- `From<Ref<T>>`
- `From<&Ref<T>>`
- `From<Ref<CroppedBitmap>>`
- `From<&Ref<CroppedBitmap>>`
- `FromIterator<Ref<Geometry>>`
- `FromIterator<Ref<GradientStop>>`
- `FromIterator<Ref<PathFigure>>`
- `FromIterator<Ref<PathSegment>>`
- `FromIterator<Ref<Transform>>`
- `FromIterator<Ref<Drawing>>`
- `From<Ref<DrawingImage>>`
- `From<&Ref<DrawingImage>>`
- `FromIterator<Ref<TextDecoration>>`
- `From<Ref<StyleBase>>`
- `From<&Ref<StyleBase>>`
- `From<Ref<Styles>>`
- `From<&Ref<Styles>>`
- [`WeakEventSender`](/docs/0.5.0/api/ferroui-base/utilities/trait-weakeventsender/)
- `Deref`
- `Clone`
- `PartialEq<Ref<U>>`
- `Eq`
- `Hash`
- `Debug`
- [`IntoRef<U>`](/docs/0.5.0/api/ferroui-base/trait-intoref/)

## Availability

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