[−][src]Struct traitcast_core::CastIntoTrait
Provides methods for casting into the target trait object from other trait objects.
Fields
map: HashMap<TypeId, ImplEntry<DynTrait>>
Methods
impl<DynTrait: ?Sized> CastIntoTrait<DynTrait>
[src]
impl<To: ?Sized + 'static> CastIntoTrait<To>
[src]
pub fn from_ref<'a, From: ?Sized>(&self, x: &'a From) -> Option<&'a To> where
From: TraitcastFrom,
[src]
From: TraitcastFrom,
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!
.
pub fn from_mut<'a, From: ?Sized>(&self, x: &'a mut From) -> Option<&'a mut To> where
From: TraitcastFrom,
[src]
From: TraitcastFrom,
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!
.
pub fn from_box<From: ?Sized>(
&self,
x: Box<From>
) -> Result<Box<To>, Box<dyn Any>> where
From: TraitcastFrom,
[src]
&self,
x: Box<From>
) -> Result<Box<To>, Box<dyn Any>> where
From: TraitcastFrom,
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
impl<DynTrait: ?Sized> FromIterator<ImplEntry<DynTrait>> for CastIntoTrait<DynTrait>
[src]
fn from_iter<T>(iter: T) -> Self where
T: IntoIterator<Item = ImplEntry<DynTrait>>,
[src]
T: IntoIterator<Item = ImplEntry<DynTrait>>,
Auto Trait Implementations
impl<DynTrait: ?Sized> Send for CastIntoTrait<DynTrait>
impl<DynTrait: ?Sized> Sync for CastIntoTrait<DynTrait>
Blanket Implementations
impl<T> TraitcastFrom for T where
T: 'static,
[src]
T: 'static,
fn as_any_ref(&Self) -> &(dyn Any + 'static)
[src]
fn as_any_mut(&mut Self) -> &mut (dyn Any + 'static)
[src]
fn as_any_box(Box<T>) -> Box<dyn Any + 'static>
[src]
fn type_id(&self) -> TypeId
[src]
Get the trait object's dynamic type id.
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> From<T> for T
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Any for T where
T: Any,
[src]
T: Any,