[][src]Struct traitcast_core::CastIntoTrait

pub struct CastIntoTrait<DynTrait: ?Sized> {
    pub map: HashMap<TypeId, ImplEntry<DynTrait>>,
}

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]

pub fn new() -> Self[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]

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]

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]

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]

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]

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]

impl<T> From<T> for T[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Any for T where
    T: Any
[src]