Struct core::kinds::marker::InvariantType[src]

pub struct InvariantType<T>;

A marker type whose type parameter T is considered to be invariant with respect to the type itself. This is (typically) used to indicate that instances of the type T may be read or written, even though that may not be apparent.

For more information about variance, refer to this Wikipedia article http://en.wikipedia.org/wiki/Variance_%28computer_science%29.

Example

The Cell type is an example which uses unsafe code to achieve "interior" mutability:

pub struct Cell<T> { value: T } fn main() {}
pub struct Cell<T> { value: T }

The type system would infer that value is only read here and never written, but in fact Cell uses unsafe code to achieve interior mutability.

Trait Implementations

Derived Implementations

impl<T: Clone> Clone for InvariantType<T>

fn clone(&self) -> InvariantType<T>

fn clone_from(&mut self, source: &Self)

impl<T: PartialEq> PartialEq for InvariantType<T>

fn eq(&self, __arg_0: &InvariantType<T>) -> bool

fn ne(&self, __arg_0: &InvariantType<T>) -> bool