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.