Trait drone_core::token::Token [−][src]
A zero-sized affine type, at most one instance of which ever exists.
The above properties can’t be expressed with Rust type-system, therefore the
trait is marked unsafe
, and it is the implementer responsibility to keep
the following invariants:
- The type must not implement
Clone
. - The type must be instantiated only inside
Token::take
method. - The type must be zero-sized.
Required methods
unsafe fn take() -> Self
[src]
Creates the token instance.
Safety
At most one instance of the token must ever exist. This invariant can’t
be expressed with Rust type-system, therefore the method is marked
unsafe
, and it is the caller responsibility to keep the invariant.
It is recommended to call this method at the very beginning of the program and pass the instance further to the code.
Since the type is ZST, the method is no-op from the assembly perspective. Likewise passing the instance around doesn’t consume the stack, and storing the instance inside other types doesn’t consume the memory.