You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

24 lines
570 B
Rust

use crate::impl_typemap;
use crate::type_indexed::TypeIndexedMap;
use multi_trait_object::{RawClone, TryClone};
impl_typemap!(
/// A typemap that can be cloned restricting all inner
/// types to implement [std::clone::Clone] as well.
CloneTypeMap,
CloneTypeMapKey,
RawClone
);
impl Clone for CloneTypeMap {
fn clone(&self) -> Self {
let map = self
.0
.0
.iter()
.map(|(t, o)| (t.clone(), o.try_clone().unwrap()))
.collect();
CloneTypeMap(TypeIndexedMap(map))
}
}