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 crate::impl_typemap;
|
||||||
use multi_trait_object::{create_object, MultitraitObject};
|
|
||||||
use std::any::Any;
|
use std::any::Any;
|
||||||
|
|
||||||
#[derive(Eq, PartialEq, Hash)]
|
impl_typemap!(
|
||||||
pub struct AnyTypeMapKey;
|
/// A typemap that can store any type (implementing [std::any::Any]).
|
||||||
|
TypeMap,
|
||||||
impl<T> TypedKeyTrait<AnyTypeMapKey> for T
|
AnyTypeMapKey,
|
||||||
where
|
Any
|
||||||
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);
|
|
||||||
|
Loading…
Reference in New Issue