Struct GhostToken

Source
pub struct GhostToken<'brand>(/* private fields */);
Expand description

WARNING: This attempt at recreating GhostCell but with traits does NOT work.

I am leaving this here because I believe there may exist a way to make this type of token work, and anyone who has ideas of how to do so is welcome to try and make a PR.

To check your theory, clone this repo and use the ghost.rs example as a check for your attempt. If your method works, the example should have some compile error.

Trait Implementations§

Source§

impl<'brand> TokenTrait for GhostToken<'brand>

Source§

type ConstructionError = ()

Source§

type RunError = Infallible

Source§

type Identifier = InvariantLifetime<'brand>

Source§

type ComparisonError = Infallible

Source§

fn new() -> Result<Self, Self::ConstructionError>

Constructs a new Token.
Source§

fn with_token<R, F: FnOnce(Self) -> R>(f: F) -> Result<R, Self::RunError>

Constructs a new Token, and provides it to the closure. Read more
Source§

fn identifier(&self) -> InvariantLifetime<'brand>

Returns the Token’s identifier, which cells may store to allow comparison.
Source§

fn compare( &self, _: &InvariantLifetime<'brand>, ) -> Result<(), Self::ComparisonError>

Allows the cell to compare its identifier to the Token.

Auto Trait Implementations§

§

impl<'brand> Freeze for GhostToken<'brand>

§

impl<'brand> !RefUnwindSafe for GhostToken<'brand>

§

impl<'brand> Send for GhostToken<'brand>

§

impl<'brand> !Sync for GhostToken<'brand>

§

impl<'brand> Unpin for GhostToken<'brand>

§

impl<'brand> UnwindSafe for GhostToken<'brand>

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