Trait DowncastTo

Source
pub trait DowncastTo<T>: Sized {
    // Required method
    fn downcast_to(&self) -> Option<T>;
}
Expand description

Our version of “try-into”. A “downcast” casts from a more general type (e.g., any Parameter) to a more specific type (e.g., a type).

This is the trait that you prefer to implement, but use DowncastFrom in where-clauses.

Required Methods§

Source

fn downcast_to(&self) -> Option<T>

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.

Implementations on Foreign Types§

Source§

impl DowncastTo<u32> for u32

Source§

impl DowncastTo<()> for ()

Source§

impl DowncastTo<usize> for usize

Source§

impl DowncastTo<String> for String

Source§

impl<A, B> DowncastTo<Vec<B>> for Vec<A>
where B: DowncastFrom<A>,

Source§

fn downcast_to(&self) -> Option<Vec<B>>

Source§

impl<A, T> DowncastTo<(A, Vec<T>)> for Vec<T>
where A: DowncastFrom<T>, T: Ord + Clone,

Source§

fn downcast_to(&self) -> Option<(A, Vec<T>)>

Source§

impl<T> DowncastTo<()> for Vec<T>

Source§

impl<T, U> DowncastTo<T> for &U
where T: DowncastFrom<U> + Clone,

Source§

fn downcast_to(&self) -> Option<T>

Implementors§