1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
use std::any::Any; /// Trait used for casting support into the Any trait object pub trait AsAny: Any { /// Converts reference to Any fn as_any(&self) -> &dyn Any; /// converts mutable reference to Any fn as_mut_any(&mut self) -> &mut dyn Any; } /// Blanket implementation that enables any `'static` reference to convert /// to the `Any` type impl<T: 'static> AsAny for T { fn as_any(&self) -> &dyn Any { self } fn as_mut_any(&mut self) -> &mut dyn Any { self } }