Skip to main content

Downcast

Trait Downcast 

Source
pub trait Downcast: ErasedType {
    // Provided methods
    fn is<T: DowncastType>(&self) -> bool { ... }
    fn downcast_ref<T: DowncastType>(&self) -> Option<&T> { ... }
    fn downcast_mut<T: DowncastType>(&mut self) -> Option<&mut T> { ... }
}
Expand description

Extension methods for deterministic concrete-type downcasting.

Provided Methods§

Source

fn is<T: DowncastType>(&self) -> bool

Returns whether the erased value has concrete type T.

Source

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

Returns the erased value as T when its key matches.

Source

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

Returns the erased value as mutable T when its key matches.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§