Crate as_any[−][src]
Expand description
This library provides some utility traits to make working with Any
smoother.
This crate contains similiar functionality to the downcast
crate, but simpler.
Usage example
use as_any::{AsAny, Downcast};
struct Test;
trait Custom: AsAny {
// whatever you like to put inside of your trait
}
// implements the downcasting methods
impl as_any::Downcast for dyn Custom {}
impl as_any::Downcast for dyn Custom + Send {}
impl as_any::Downcast for dyn Custom + Sync {}
impl as_any::Downcast for dyn Custom + Send + Sync {}
impl Custom for Test {}
fn lol() {
let x = Test;
let y: &dyn Custom = &x;
y.downcast_ref::<Test>().unwrap();
}