Struct RefToken

Source
pub struct RefToken<T: ?Sized>(/* private fields */);
Expand description

Abstraction of a reference as a token.

The reference should point to a pinned object, otherwise moving the object will “invalidate” the cells initialized with the previous reference.

Implementations§

Source§

impl<T: ?Sized> RefToken<T>

Source

pub fn from_ref(t: &T) -> &Self
where T: Unpin,

Convert an immutable reference into an immutable RefToken reference.

Source

pub fn from_mut(t: &mut T) -> &mut Self
where T: Unpin,

Convert a mutable reference into a mutable RefToken reference.

Source

pub fn from_pin(t: Pin<&T>) -> &Self

Convert a pinned immutable reference into an immutable RefToken reference.

Source

pub fn from_pin_mut(t: Pin<&mut T>) -> &mut Self

Convert a pinned mutable reference into a mutable RefToken reference.

Source

pub fn as_pin(&self) -> Pin<&T>

Get a pinned immutable reference.

Source

pub fn as_pin_mut(&mut self) -> Pin<&mut T>

Get a pinned mutable reference.

Trait Implementations§

Source§

impl<T: Unpin + ?Sized> AsMut<T> for RefToken<T>

Source§

fn as_mut(&mut self) -> &mut T

Converts this type into a mutable reference of the (usually inferred) input type.
Source§

impl<T: ?Sized> AsRef<T> for RefToken<T>

Source§

fn as_ref(&self) -> &T

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl<T: Debug + ?Sized> Debug for RefToken<T>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<T: ?Sized> Deref for RefToken<T>

Source§

type Target = T

The resulting type after dereferencing.
Source§

fn deref(&self) -> &Self::Target

Dereferences the value.
Source§

impl<T: Unpin + ?Sized> DerefMut for RefToken<T>

Source§

fn deref_mut(&mut self) -> &mut Self::Target

Mutably dereferences the value.
Source§

impl<'a, T: Unpin + ?Sized> From<&'a T> for &'a RefToken<T>

Source§

fn from(value: &'a T) -> Self

Converts to this type from the input type.
Source§

impl<'a, T: Unpin + ?Sized> From<&'a mut T> for &'a mut RefToken<T>

Source§

fn from(value: &'a mut T) -> Self

Converts to this type from the input type.
Source§

impl<'a, T: ?Sized> From<Pin<&'a T>> for &'a RefToken<T>

Source§

fn from(value: Pin<&'a T>) -> Self

Converts to this type from the input type.
Source§

impl<'a, T: ?Sized> From<Pin<&'a mut T>> for &'a mut RefToken<T>

Source§

fn from(value: Pin<&'a mut T>) -> Self

Converts to this type from the input type.
Source§

impl<T: ?Sized> Token for RefToken<T>

Source§

type Id = PtrId<T>

Id of the token.
Source§

fn id(&self) -> Self::Id

Returns the token id.
Source§

fn is_unique(&mut self) -> bool

Returns true if the token is “unique”, see safety

Auto Trait Implementations§

§

impl<T> Freeze for RefToken<T>
where T: Freeze + ?Sized,

§

impl<T> RefUnwindSafe for RefToken<T>
where T: RefUnwindSafe + ?Sized,

§

impl<T> Send for RefToken<T>
where T: Send + ?Sized,

§

impl<T> Sync for RefToken<T>
where T: Sync + ?Sized,

§

impl<T> Unpin for RefToken<T>
where T: Unpin + ?Sized,

§

impl<T> UnwindSafe for RefToken<T>
where T: UnwindSafe + ?Sized,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

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

Source§

impl<P, T> Receiver for P
where P: Deref<Target = T> + ?Sized, T: ?Sized,

Source§

type Target = T

🔬This is a nightly-only experimental API. (arbitrary_self_types)
The target type on which the method may be called.
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.