Trait as_any::Downcast

source ·
pub trait Downcast: AsAny {
    // Provided methods
    fn is<T>(&self) -> bool
       where T: AsAny { ... }
    fn downcast_ref<T>(&self) -> Option<&T>
       where T: AsAny { ... }
    fn downcast_mut<T>(&mut self) -> Option<&mut T>
       where T: AsAny { ... }
}
Expand description

This is a shim around AaAny to avoid some boilerplate code. It is a separate trait because it is also implemented on runtime polymorphic traits (which are !Sized).

Provided Methods§

source

fn is<T>(&self) -> bool
where T: AsAny,

Returns true if the boxed type is the same as T.

Forward to the method defined on the type Any.

source

fn downcast_ref<T>(&self) -> Option<&T>
where T: AsAny,

Forward to the method defined on the type Any.

source

fn downcast_mut<T>(&mut self) -> Option<&mut T>
where T: AsAny,

Forward to the method defined on the type Any.

Object Safety§

This trait is not object safe.

Implementors§

source§

impl<T: ?Sized + AsAny> Downcast for T