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

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

PhantomData is a way to tell the compiler about fake fields. Phantom data is required whenever type parameters are not used. The idea is that if the compiler encounters a PhantomData<T> instance, it will behave as if an instance of the type T were present for the purpose of various automatic analyses.

For example, embedding a PhantomData<T> will inform the compiler that one or more instances of the type T could be dropped when instances of the type itself is dropped, though that may not be apparent from the other structure of the type itself. This is commonly necessary if the structure is using an unsafe pointer like *mut T whose referent may be dropped when the type is dropped, as a *mut T is otherwise not treated as owned.

FIXME. Better documentation and examples of common patterns needed here! For now, please see RFC 738 for more information.

Trait Implementations

impl<T> Hash for PhantomData<T> where T: ?Sized

fn hash<H>(&self, &mut H) where H: Hasher

fn hash_slice<H>(&[PhantomData<T>], &mut H) where H: Hasher, PhantomData<T>: Sized

impl<T> PartialEq<PhantomData<T>> for PhantomData<T> where T: ?Sized

fn eq(&self, _other: &PhantomData<T>) -> bool

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

impl<T> Eq for PhantomData<T> where T: ?Sized

fn assert_receiver_is_total_eq(&self)

impl<T> PartialOrd<PhantomData<T>> for PhantomData<T> where T: ?Sized

fn partial_cmp(&self, _other: &PhantomData<T>) -> Option<Ordering>

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

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

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

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

impl<T> Ord for PhantomData<T> where T: ?Sized

fn cmp(&self, _other: &PhantomData<T>) -> Ordering

impl<T> Copy for PhantomData<T> where T: ?Sized

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

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

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

impl<T> Debug for PhantomData<T>

fn fmt(&self, f: &mut Formatter) -> Result<(), Error>