[][src]Trait intertrait::CastFrom

pub trait CastFrom: Any + 'static {
    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>; }

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

This example is not tested
trait Source: CastFrom {
    ...
}

Required methods

fn ref_any(&self) -> &dyn Any

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

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

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

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

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

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

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

Loading content...

Implementations on Foreign Types

impl CastFrom for dyn Any + 'static[src]

impl CastFrom for dyn Any + Sync + Send + 'static[src]

Loading content...

Implementors

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

Loading content...