pub struct Weak<T: ?Sized, Owner: ?Sized = dyn Destruct> { /* private fields */ }
Expand description

A projecting version of Weak which allows owning a containing struct but referencing a field.

Implementations

Constructs a new Weak<T>

Returns a raw pointer to the object T pointed to by this Weak<T>.

The pointer is valid only if there are some strong references. The pointer may be dangling, unaligned, or even null otherwise.

Attempts to upgrade the Weak pointer to Arc<T>.

Returns None if no strong references exist.

Gets a reference to the owning allocation.

Consumes this projected field, returning the owning allocation.

Projects this allocation to a field.

If no strong references exist, the closure will not be called.

Returns true if the two Weaks point to the same allocation (similar to ptr::eq), or if both don’t point to any allocation (because they were crated with Weak::new()).

Available on crate feature unsize only.

Convert this pointer with an unsizing coercion (e.g. from T to dyn Trait or [T; N] to [T]).

Available on crate feature unsize only.

Convert this pointer with an unsizing coercion of the owner (e.g. from T to dyn Trait or [T; N] to [T]).

Trait Implementations

Returns a copy of the value. Read more
Performs copy-assignment from source. Read more
The type we point to. This influences which kinds of unsizing are possible. Read more
The output type when unsizing the pointee to U.
Get the raw inner pointer.
Replace the container inner pointer with an unsized version. Read more
Formats the value using the given formatter. Read more
Returns the “default value” for a type. Read more
Converts to this type from the input type.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more
Convert a pointer, as if with unsize coercion. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The resulting type after obtaining ownership.
Creates owned data from borrowed data, usually by cloning. Read more
Uses borrowed data to replace owned data, usually by cloning. Read more
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.