On this page
Struct std::ptr::DynMetadata
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 it contains:
- type size
- type alignment
- a pointer to the type’s
drop_in_place
impl (may be a no-op for plain-old-data) - pointers to all the methods for the type’s implementation of the trait
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.
Implementations
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
Trait Implementations
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) -> Self
where
Self: Sized,
fn min(self, other: Self) -> Self
where
Self: Sized,
fn clamp(self, min: Self, max: Self) -> Self
where
Self: Sized + PartialOrd,
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
self
and other
) and is used by the <=
operator. Read more
fn gt(&self, other: &Rhs) -> bool
fn ge(&self, other: &Rhs) -> bool
self
and other
) and is used by the >=
operator. Read more
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,
Auto Trait Implementations
impl<Dyn> !RefUnwindSafe for DynMetadata<Dyn>
impl<Dyn> !UnwindSafe for DynMetadata<Dyn>
Blanket Implementations
impl<T> Any for T
where
T: 'static + ?Sized,
impl<T> Borrow<T> for T
where
T: ?Sized,
impl<T> BorrowMut<T> for T
where
T: ?Sized,
impl<T> From<T> for T
fn from(t: T) -> T
Returns the argument unchanged.
impl<T, U> Into<U> for T
where
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 T
where
T: Clone,
type Owned = T
fn to_owned(&self) -> T
fn clone_into(&self, target: &mut T)
impl<T, U> TryFrom<U> for T
where
U: Into<T>,
type Error = Infallible
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
impl<T, U> TryInto<U> for T
where
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
© 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