# WeakRef

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

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

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

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

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

## Members

- [`upgrade`](#function-upgrade)
- [`upcast`](#function-upcast)
- [`points_to`](#function-points_to)
- [`ptr_eq`](#function-ptr_eq)

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

### upgrade

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

Returns a strong reference if the object is still alive.

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

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

### upcast

```rust
fn upcast<U: ObjectType>(self: Self) -> WeakRef<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#L1131)

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

### points_to

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

Whether the weak reference points at `object`.

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

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

### ptr_eq

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

Whether two weak references point at the same object, alive or not.

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

## Trait implementations

- `Send`
- `Sync`
- `Freeze`
- `UnsafeUnpin`
- `Unpin`
- `UnwindSafe`
- `RefUnwindSafe`
- [`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`

## Availability

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