CastFrom

Trait CastFrom 

Source
pub trait CastFrom: Any + 'static {
    // Required methods
    fn ref_any(&self) -> &dyn Any;
    fn mut_any(&mut self) -> &mut dyn Any;
    fn box_any(self: Box<Self>) -> Box<dyn Any>;
    fn rc_any(self: Rc<Self>) -> Rc<dyn Any>;
}
Expand description

CastFrom must be extended by a trait that wants to allow for casting into another trait.

It is used for obtaining a trait object for Any from a trait object for its sub-trait, and blanket implemented for all Sized + Any + 'static types.

§Examples

trait Source: CastFrom {
    ...
}

Required Methods§

Source

fn ref_any(&self) -> &dyn Any

Returns a immutable reference to Any, which is backed by the type implementing this trait.

Source

fn mut_any(&mut self) -> &mut dyn Any

Returns a mutable reference to Any, which is backed by the type implementing this trait.

Source

fn box_any(self: Box<Self>) -> Box<dyn Any>

Returns a Box of Any, which is backed by the type implementing this trait.

Source

fn rc_any(self: Rc<Self>) -> Rc<dyn Any>

Returns an Rc of Any, which is backed by the type implementing this trait.

Implementations on Foreign Types§

Source§

impl CastFrom for dyn Any + 'static

Source§

fn ref_any(&self) -> &dyn Any

Source§

fn mut_any(&mut self) -> &mut dyn Any

Source§

fn box_any(self: Box<Self>) -> Box<dyn Any>

Source§

fn rc_any(self: Rc<Self>) -> Rc<dyn Any>

Source§

impl CastFrom for dyn Any + Sync + Send + 'static

Source§

fn ref_any(&self) -> &dyn Any

Source§

fn mut_any(&mut self) -> &mut dyn Any

Source§

fn box_any(self: Box<Self>) -> Box<dyn Any>

Source§

fn rc_any(self: Rc<Self>) -> Rc<dyn Any>

Implementors§

Source§

impl<T: Sized + Any + 'static> CastFrom for T