pub struct DynMetadata<Dyn>where
Dyn: ?Sized,{ /* private fields */ }
ptr_metadata #81513)
The metadata for a Dyn = dyn SomeTrait trait object type.
It is a pointer to a vtable (virtual call table) that represents all the necessary information to manipulate the concrete type stored inside a trait object. The vtable notably contains:
drop_in_place impl (may be a no-op for plain-old-data)Note that the first three are special because they’re necessary to allocate, drop, and deallocate any trait object.
It is possible to name this struct with a type parameter that is not a dyn trait object (for example DynMetadata<u64>) but not to obtain a meaningful value of that struct.
Note that while this type implements PartialEq, comparing vtable pointers is unreliable: pointers to vtables of the same type for the same trait can compare inequal (because vtables are duplicated in multiple codegen units), and pointers to vtables of different types/traits can compare equal (since identical vtables can be deduplicated within a codegen unit).
impl<Dyn> DynMetadata<Dyn>where
Dyn: ?Sized,pub fn size_of(self) -> usize
ptr_metadata #81513)
Returns the size of the type associated with this vtable.
pub fn align_of(self) -> usize
ptr_metadata #81513)
Returns the alignment of the type associated with this vtable.
pub fn layout(self) -> Layout
ptr_metadata #81513)
Returns the size and alignment together as a Layout
impl<Dyn> Clone for DynMetadata<Dyn>where
Dyn: ?Sized,fn clone(&self) -> DynMetadata<Dyn>
fn clone_from(&mut self, source: &Self)
source. Read more
impl<Dyn> Debug for DynMetadata<Dyn>where
Dyn: ?Sized,fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>
impl<Dyn> Hash for DynMetadata<Dyn>where
Dyn: ?Sized,fn hash<H>(&self, hasher: &mut H)where
H: Hasher,fn hash_slice<H>(data: &[Self], state: &mut H)where
H: Hasher,
Self: Sized,impl<Dyn> Ord for DynMetadata<Dyn>where
Dyn: ?Sized,fn cmp(&self, other: &DynMetadata<Dyn>) -> Ordering
fn max(self, other: Self) -> Selfwhere
Self: Sized,fn min(self, other: Self) -> Selfwhere
Self: Sized,fn clamp(self, min: Self, max: Self) -> Selfwhere
Self: Sized,impl<Dyn> PartialEq for DynMetadata<Dyn>where
Dyn: ?Sized,fn eq(&self, other: &DynMetadata<Dyn>) -> bool
self and other values to be equal, and is used by ==.fn ne(&self, other: &Rhs) -> bool
!=. The default implementation is almost always sufficient, and should not be overridden without very good reason.impl<Dyn> PartialOrd for DynMetadata<Dyn>where
Dyn: ?Sized,fn partial_cmp(&self, other: &DynMetadata<Dyn>) -> Option<Ordering>
fn lt(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
fn gt(&self, other: &Rhs) -> bool
fn ge(&self, other: &Rhs) -> bool
impl<Dyn> Copy for DynMetadata<Dyn>where
Dyn: ?Sized,impl<Dyn> Eq for DynMetadata<Dyn>where
Dyn: ?Sized,impl<Dyn> Send for DynMetadata<Dyn>where
Dyn: ?Sized,impl<Dyn> Sync for DynMetadata<Dyn>where
Dyn: ?Sized,impl<Dyn> Unpin for DynMetadata<Dyn>where
Dyn: ?Sized,impl<Dyn> Freeze for DynMetadata<Dyn>where
Dyn: ?Sized,impl<Dyn> !RefUnwindSafe for DynMetadata<Dyn>
impl<Dyn> !UnwindSafe for DynMetadata<Dyn>
impl<T> Any for Twhere
T: 'static + ?Sized,impl<T> Borrow<T> for Twhere
T: ?Sized,impl<T> BorrowMut<T> for Twhere
T: ?Sized,impl<T> CloneToUninit for Twhere
T: Clone,unsafe fn clone_to_uninit(&self, dest: *mut u8)
clone_to_uninit #126799)
impl<T> From<T> for T
fn from(t: T) -> T
Returns the argument unchanged.
impl<T, U> Into<U> for Twhere
U: From<T>,fn into(self) -> U
Calls U::from(self).
That is, this conversion is whatever the implementation of From<T> for U chooses to do.
impl<T> ToOwned for Twhere
T: Clone,type Owned = T
fn to_owned(&self) -> T
fn clone_into(&self, target: &mut T)
impl<T, U> TryFrom<U> for Twhere
U: Into<T>,type Error = Infallible
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
impl<T, U> TryInto<U> for Twhere
U: TryFrom<T>,
© 2010 The Rust Project Developers
Licensed under the Apache License, Version 2.0 or the MIT license, at your option.
https://doc.rust-lang.org/std/ptr/struct.DynMetadata.html