pub struct PhantomData<T: ?Sized>(/* private fields */);Expand description
Zero-sized type used to mark things that “act like” they own a T.
PhantomData
Common use cases:
- Generic wrapper types that don’t directly store T
- Type-safe handles/IDs that track what they point to
- Zero-cost type-level state machines
§Examples
use windjammer_runtime::marker::PhantomData;
// Type-safe buffer handle
pub struct BufferId<T> {
id: u32,
_phantom: PhantomData<T>,
}
// Compiler knows this BufferId is for CameraUniforms
let camera_buffer: BufferId<CameraUniforms> = BufferId {
id: 42,
_phantom: PhantomData,
};Implementations§
Source§impl<T: ?Sized> PhantomData<T>
impl<T: ?Sized> PhantomData<T>
Sourcepub const fn new() -> PhantomData<T>
pub const fn new() -> PhantomData<T>
Creates a new PhantomData.
Trait Implementations§
Source§impl<T: Clone + ?Sized> Clone for PhantomData<T>
impl<T: Clone + ?Sized> Clone for PhantomData<T>
Source§fn clone(&self) -> PhantomData<T>
fn clone(&self) -> PhantomData<T>
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl<T: Default + ?Sized> Default for PhantomData<T>
impl<T: Default + ?Sized> Default for PhantomData<T>
Source§fn default() -> PhantomData<T>
fn default() -> PhantomData<T>
Returns the “default value” for a type. Read more
Source§impl<T: Ord + ?Sized> Ord for PhantomData<T>
impl<T: Ord + ?Sized> Ord for PhantomData<T>
Source§fn cmp(&self, other: &PhantomData<T>) -> Ordering
fn cmp(&self, other: &PhantomData<T>) -> Ordering
1.21.0 (const: unstable) · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the maximum of two values. Read more
Source§impl<T: PartialEq + ?Sized> PartialEq for PhantomData<T>
impl<T: PartialEq + ?Sized> PartialEq for PhantomData<T>
Source§fn eq(&self, other: &PhantomData<T>) -> bool
fn eq(&self, other: &PhantomData<T>) -> bool
Tests for
self and other values to be equal, and is used by ==.Source§impl<T: PartialOrd + ?Sized> PartialOrd for PhantomData<T>
impl<T: PartialOrd + ?Sized> PartialOrd for PhantomData<T>
impl<T: Copy + ?Sized> Copy for PhantomData<T>
impl<T: Eq + ?Sized> Eq for PhantomData<T>
impl<T: ?Sized> StructuralPartialEq for PhantomData<T>
Auto Trait Implementations§
impl<T> Freeze for PhantomData<T>where
T: ?Sized,
impl<T> RefUnwindSafe for PhantomData<T>where
T: RefUnwindSafe + ?Sized,
impl<T> Send for PhantomData<T>
impl<T> Sync for PhantomData<T>
impl<T> Unpin for PhantomData<T>
impl<T> UnsafeUnpin for PhantomData<T>where
T: ?Sized,
impl<T> UnwindSafe for PhantomData<T>where
T: UnwindSafe + ?Sized,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more