Struct pin_cell::PinCell

source ·
pub struct PinCell<T: ?Sized> { /* private fields */ }
Expand description

A mutable memory location with dynamically checked borrow rules

Unlike RefCell, this type only allows pinned mutable access to the inner value, enabling a “pin-safe” version of interior mutability.

See the standard library documentation for more information.

Implementations

Creates a new PinCell containing value.

Immutably borrows the wrapped value.

The borrow lasts until the returned Ref exits scope. Multiple immutable borrows can be taken out at the same time (both pinned and unpinned).

Immutably borrows the wrapped value, returning an error if the value is currently mutably borrowed.

The borrow lasts until the returned Ref exits scope. Multiple immutable borrows can be taken out at the same time (both pinned and unpinned).

This is the non-panicking variant of borrow.

Mutably borrows the wrapped value, preserving its pinnedness.

The borrow lasts until the returned PinMut or all PinMuts derived from it exit scope. The value cannot be borrowed while this borrow is active.

Mutably borrows the wrapped value, preserving its pinnedness, returning an error if the value is currently borrowed.

The borrow lasts until the returned PinMut or all PinMuts derived from it exit scope. The value cannot be borrowed while this borrow is active.

This is the non-panicking variant of borrow_mut.

Immutably borrows the wrapped value, preserving its pinnedness.

The borrow lasts until the returned PinRef exits scope. Multiple immutable borrows can be taken out at the same time (both pinned and unpinned).

Immutably borrows the wrapped value, preserving its pinnedness, returning an error if the value is currently mutably borrowed.

The borrow lasts until the returned PinRef exits scope. Multiple immutable borrows can be taken out at the same time (both pinned and unpinned).

This is the non-panicking variant of borrow_pin.

Returns a raw pointer to the underlying data in this cell.

Returns a mutable reference to the underlying data.

This call borrows PinCell mutably (at compile-time) so there is no need for dynamic checks.

However be cautious: this method expects self to be mutable, which is generally not the case when using a PinCell. Take a look at the borrow_mut method instead if self isn’t mutable.

Also, please be aware that this method is only for special circumstances and is usually not what you want. In case of doubt, use borrow_mut instead.

Trait Implementations

Returns a copy of the value. Read more
Performs copy-assignment from source. 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.
Converts to this type from the input type.
Converts this type into the (usually inferred) input type.
This method returns an Ordering between self and other. Read more
This method tests for self and other values to be equal, and is used by ==. Read more
This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason. Read more
This method returns an ordering between self and other values if one exists. Read more
This method tests less than (for self and other) and is used by the < operator. Read more
This method tests less than or equal to (for self and other) and is used by the <= operator. Read more
This method tests greater than (for self and other) and is used by the > operator. Read more
This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more

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
Converts to this type from the input type.

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 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.