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