Struct singleton_trait::Erased[][src]

pub struct Erased<T> { /* fields omitted */ }
Expand description

The Exists struct witnesses the logical ownership of a value of type T while remaining zero-sized. This can be used for ghost proofs of soundness.

Erased should be thought of a zero-sized owner of T.

NOTE: drop implementations will never be called, as Exists guarantees the existence of a valid T, which might not be true if they were called. On the other hand, since it does not hold a T, it cannot drop T when it is itself dropped

Secondly, keep in mind that while Exists serves as evidence, it does not include sufficient providence for either Stacked Borrows or LLVM, and so it is not sound in general to recover a reference from an Exists<&T> and *mut T or &UnsafeCell<T> even when T is Singleton, but this could be possible if T is zero-sized.

Implementations

This function constructs a value of Erased without taking logical ownership of a T.

Safety

Constructing this asserts that there is a value of type T which has been leaked, or in which it is guaranteed that the program behaves the same up to observation as if a zero-sized copy of T were being passed.

Maps a function on the inside of the Erased body (existential induction).

Safety

Due to the strictness guarantees, the passed closure must not cause any visible side effects, including side effects caused by owning R

Maps a function on the borrow of the Erased field (existential induction).

Safety

Due to the strictness guarantees, the passed closure must not cause any visible side effects, including side effects caused by owning R

Maps a function on the mutable borrow of the Erased field.

Safety

Due to the strictness guarantees, the passed closure must not cause any visible side effects, including side effects caused by owning R

An erased erased value can be flattened into a single erasure, since Erased is notionally equivalent to T

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Performs the conversion.

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

Performs the conversion.

Performs the conversion.

Performs the conversion.

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.