pub struct CastIntoTrait<DynTrait: ?Sized> {
pub map: HashMap<TypeId, ImplEntry<DynTrait>>,
}
Expand description
Provides methods for casting into the target trait object from other trait objects.
Fields§
§map: HashMap<TypeId, ImplEntry<DynTrait>>
Implementations§
Source§impl<To: ?Sized + 'static> CastIntoTrait<To>
impl<To: ?Sized + 'static> CastIntoTrait<To>
Sourcepub fn from_ref<'a, From>(&self, x: &'a From) -> Option<&'a To>where
From: TraitcastFrom + ?Sized,
pub fn from_ref<'a, From>(&self, x: &'a From) -> Option<&'a To>where
From: TraitcastFrom + ?Sized,
Tries to cast the given reference to a dynamic trait object. This will
always return None if the implementation of the target trait, for the
concrete type of x, has not been registered via traitcast_to_impl!
.
Sourcepub fn from_mut<'a, From>(&self, x: &'a mut From) -> Option<&'a mut To>where
From: TraitcastFrom + ?Sized,
pub fn from_mut<'a, From>(&self, x: &'a mut From) -> Option<&'a mut To>where
From: TraitcastFrom + ?Sized,
Tries to cast the given mutable reference to a dynamic trait object.
This will always return None if the implementation of the target trait,
for the concrete type of x, has not been registered via
traitcast_to_impl!
.
Sourcepub fn from_box<From>(&self, x: Box<From>) -> Result<Box<To>, Box<dyn Any>>where
From: TraitcastFrom + ?Sized,
pub fn from_box<From>(&self, x: Box<From>) -> Result<Box<To>, Box<dyn Any>>where
From: TraitcastFrom + ?Sized,
Tries to cast the given pointer to a dynamic trait object. This will
always return Err if the implementation of the target trait, for the
concrete type of x, has not been registered via traitcast_to_impl!
.
Trait Implementations§
Source§impl<DynTrait: ?Sized> FromIterator<ImplEntry<DynTrait>> for CastIntoTrait<DynTrait>
impl<DynTrait: ?Sized> FromIterator<ImplEntry<DynTrait>> for CastIntoTrait<DynTrait>
Auto Trait Implementations§
impl<DynTrait> Freeze for CastIntoTrait<DynTrait>where
DynTrait: ?Sized,
impl<DynTrait> RefUnwindSafe for CastIntoTrait<DynTrait>where
DynTrait: ?Sized,
impl<DynTrait> Send for CastIntoTrait<DynTrait>where
DynTrait: ?Sized,
impl<DynTrait> Sync for CastIntoTrait<DynTrait>where
DynTrait: ?Sized,
impl<DynTrait> Unpin for CastIntoTrait<DynTrait>where
DynTrait: ?Sized,
impl<DynTrait> UnwindSafe for CastIntoTrait<DynTrait>where
DynTrait: ?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> TraitcastFrom for Twhere
T: 'static,
impl<T> TraitcastFrom for Twhere
T: 'static,
Source§fn as_any_ref(&self) -> &(dyn Any + 'static)
fn as_any_ref(&self) -> &(dyn Any + 'static)
Cast to an immutable reference to a trait object.
Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
Cast to a mutable reference to a trait object.