pub struct TraitObject { /* private fields */ }Expand description
Type erased carrier of a dyn trait fat pointer
Implementations§
Source§impl TraitObject
impl TraitObject
Sourcepub fn zero() -> TraitObject
pub fn zero() -> TraitObject
Returns a TraitObject with two null ptrs. This value must never be used, but can serve as a default before the real value is written.
Sourcepub fn as_mut_ptr<T: ?Sized>(self) -> *mut T
pub fn as_mut_ptr<T: ?Sized>(self) -> *mut T
Interpret this TraitObject as *mut T. *mut T MUST be a fat pointer of the same type as was used to create this TraitObject instance.
Sourcepub fn as_const_ptr<T: ?Sized>(self) -> *const T
pub fn as_const_ptr<T: ?Sized>(self) -> *const T
Interpret this TraitObject as *const T. *const T MUST be a fat pointer of the same type as was used to create this TraitObject instance.
Sourcepub fn new_from_ptr<T: ?Sized>(raw: *const T) -> TraitObject
pub fn new_from_ptr<T: ?Sized>(raw: *const T) -> TraitObject
Convert the given fat pointer to a TraitObject instance.
Sourcepub fn new<T: ?Sized>(input: Box<T>) -> TraitObject
pub fn new<T: ?Sized>(input: Box<T>) -> TraitObject
Note: This only works for boxed dyn Trait.
T must be dyn SomeTrait.
Trait Implementations§
Source§impl Clone for TraitObject
impl Clone for TraitObject
Source§fn clone(&self) -> TraitObject
fn clone(&self) -> TraitObject
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for TraitObject
impl Debug for TraitObject
impl Copy for TraitObject
impl Send for TraitObject
impl Sync for TraitObject
Auto Trait Implementations§
impl Freeze for TraitObject
impl RefUnwindSafe for TraitObject
impl Unpin for TraitObject
impl UnwindSafe for TraitObject
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