2023-09-08 04:13:46 +00:00
|
|
|
use std::any::Any;
|
2023-09-01 01:34:58 +00:00
|
|
|
|
2024-03-31 17:24:32 +00:00
|
|
|
/// A trait that is implemented for types that are `Send + Sync + 'static`.
|
|
|
|
pub trait AsSyncAny: Send + Sync + 'static {
|
2023-07-16 04:39:54 +00:00
|
|
|
fn as_any(&self) -> &dyn Any;
|
|
|
|
fn as_any_mut(&mut self) -> &mut dyn Any;
|
|
|
|
}
|
|
|
|
|
2023-09-01 01:34:58 +00:00
|
|
|
/// Implements this trait for anything that fits the type bounds
|
2024-03-31 17:24:32 +00:00
|
|
|
impl<T: Send + Sync + 'static> AsSyncAny for T {
|
2023-07-16 04:39:54 +00:00
|
|
|
fn as_any(&self) -> &dyn Any {
|
|
|
|
self
|
|
|
|
}
|
|
|
|
|
|
|
|
fn as_any_mut(&mut self) -> &mut dyn Any {
|
|
|
|
self
|
|
|
|
}
|
|
|
|
}
|