AnyExt

Trait AnyExt 

Source
pub trait AnyExt: Any {
    // Provided methods
    fn is<T: Any + ?Sized>(&self) -> bool { ... }
    fn downcast_ref<T: Any>(&self) -> Option<&T> { ... }
    fn downcast_mut<T: Any>(&mut self) -> Option<&mut T> { ... }
}
Expand description

Extension of Any for using its methods directly on the value without dyn.

Provided Methods§

Source

fn is<T: Any + ?Sized>(&self) -> bool

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

Source

fn downcast_ref<T: Any>(&self) -> Option<&T>

Returns Some reference to this value if it’s of type T, or None otherwise.

Source

fn downcast_mut<T: Any>(&mut self) -> Option<&mut T>

Returns Some mutable reference to this value if it’s of type T, or None otherwise.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§

Source§

impl<T: Any + ?Sized> AnyExt for T