[−][src]Trait cast_trait_object::DynCast
Cast a trait object (T::Source
) into a different trait object (T::Target
).
This trait is object safe and provides methods to convert from one fat pointer
to another. This can be used as a supertrait or via trait bounds to allow
casting between two different trait objects. But for usage it is more ergonomic
to use the methods that are provided by the DynCastExt
trait than to call
the methods on this trait directly.
Required methods
fn dyn_cast_ref(&self) -> Result<&T::Target, &T::Source>
Cast a shared reference of this trait object to another trait object.
fn dyn_cast_mut(&mut self) -> Result<&mut T::Target, &mut T::Source>
Cast a mutable/unique reference of this trait object to another trait object.
fn dyn_cast_boxed(self: Box<Self>) -> Result<Box<T::Target>, Box<T::Source>>
This is supported on crate feature
alloc
only.Cast a boxed trait object to another trait object.
fn dyn_cast_rc(self: Rc<Self>) -> Result<Rc<T::Target>, Rc<T::Source>>
This is supported on crate feature
alloc
only.Cast a reference counted trait object to another trait object.
fn dyn_cast_arc(self: Arc<Self>) -> Result<Arc<T::Target>, Arc<T::Source>>
This is supported on crate feature
alloc
only.Cast an atomically reference counted trait object to another trait object.
Implementors
impl<C, T> DynCast<C> for T where
C: DynCastConfig,
T: DerivedDynCast<ConcreteDynCastConfig<C::Source, C::Target>, C>,
[src]
C: DynCastConfig,
T: DerivedDynCast<ConcreteDynCastConfig<C::Source, C::Target>, C>,