Add comments to impl_typemap macro
Signed-off-by: trivernis <trivernis@protonmail.com>main
parent
14e369449e
commit
b7d7b83b0d
@ -1,22 +1,9 @@
|
||||
use crate::{impl_typemap, TypeMapKey, TypedKeyMto, TypedKeyTrait};
|
||||
use multi_trait_object::{create_object, MultitraitObject};
|
||||
use crate::impl_typemap;
|
||||
use std::any::Any;
|
||||
|
||||
#[derive(Eq, PartialEq, Hash)]
|
||||
pub struct AnyTypeMapKey;
|
||||
|
||||
impl<T> TypedKeyTrait<AnyTypeMapKey> for T
|
||||
where
|
||||
T: TypeMapKey,
|
||||
<T as TypeMapKey>::Value: Any,
|
||||
{
|
||||
type Value = T::Value;
|
||||
}
|
||||
|
||||
impl<T: 'static> TypedKeyMto<AnyTypeMapKey> for T {
|
||||
fn into_mto(self) -> MultitraitObject {
|
||||
create_object!(self, dyn Any)
|
||||
}
|
||||
}
|
||||
|
||||
impl_typemap!(TypeMap, AnyTypeMapKey);
|
||||
impl_typemap!(
|
||||
/// A typemap that can store any type (implementing [std::any::Any]).
|
||||
TypeMap,
|
||||
AnyTypeMapKey,
|
||||
Any
|
||||
);
|
||||
|
Loading…
Reference in New Issue