Macro downcast::downcast_methods[][src]

macro_rules! downcast_methods {
    ($($tt : tt) +) => { ... };
}
Expand description

Generate downcast-methods for your trait-object-type.

downcast_methods!(Foo);
downcast_methods!(<B> Foo<B> where B: Bar);
downcast_methods!(<B> Foo<Bar = B>);
impl dyn Foo {
/* impl<B> dyn Foo<B> where B: Bar {  */
/* impl<B> dyn Foo<Bar = B> {  */

    pub fn is<T>(&self) -> bool
        where T: Any, Self: Downcast<T>
    { ... }

    pub fn downcast_ref<T>(&self) -> Result<&T, TypeMismatch>
        where T: Any, Self: Downcast<T>
    { ... }

    pub fn downcast_mut<T>(&mut self) -> Result<&mut T, TypeMismatch>
        where T: Any, Self: Downcast<T>
    { ... }

    pub fn downcast<T>(self: Box<Self>) -> Result<Box<T>, DowncastError<Box<T>>>
        where T: Any, Self: Downcast<T>
    { ... }
}