Struct std::kinds::marker::InvariantTypeExperimental [-]  [+] [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

impl<T> Copy for InvariantType<T>

impl<T> Clone for InvariantType<T>

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

fn clone_from(&mut self, &InvariantType<T>)

Derived Implementations

impl<T: Ord> Ord for InvariantType<T>

fn cmp(&self, __arg_0: &InvariantType<T>) -> Ordering

impl<T: PartialOrd<T>> PartialOrd<InvariantType<T>> for InvariantType<T>

fn partial_cmp(&self, __arg_0: &InvariantType<T>) -> Option<Ordering>

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

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

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

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

fn lt(&self, &InvariantType<T>) -> bool

fn le(&self, &InvariantType<T>) -> bool

fn gt(&self, &InvariantType<T>) -> bool

fn ge(&self, &InvariantType<T>) -> bool

impl<T: Eq> Eq for InvariantType<T>

fn assert_receiver_is_total_eq(&self)

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

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

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

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