Struct std::marker::InvariantTypeUnstable [-]  [+] [src]

pub struct InvariantType<T> where T: ?Sized;

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:

fn main() { struct Cell<T> { value: T } }
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> where T: ?Sized

impl<T> Clone for InvariantType<T> where T: ?Sized

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

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

Derived Implementations

impl<T> Ord for InvariantType<T> where T: Ord, T: ?Sized

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

impl<T> PartialOrd<InvariantType<T>> for InvariantType<T> where T: PartialOrd<T>, T: ?Sized

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 for InvariantType<T> where T: Eq, T: ?Sized

fn assert_receiver_is_total_eq(&self)

impl<T> PartialEq<InvariantType<T>> for InvariantType<T> where T: PartialEq<T>, T: ?Sized

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

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

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