lyra-engine/lyra-game/src/as_any.rs

18 lines
460 B
Rust

use std::any::Any;
/// A trait that is implemented for types that are `Send + Sync + 'static`.
pub trait AsSyncAny: Send + Sync + 'static {
fn as_any(&self) -> &dyn Any;
fn as_any_mut(&mut self) -> &mut dyn Any;
}
/// Implements this trait for anything that fits the type bounds
impl<T: Send + Sync + 'static> AsSyncAny for T {
fn as_any(&self) -> &dyn Any {
self
}
fn as_any_mut(&mut self) -> &mut dyn Any {
self
}
}