Add typemap that is Send + Sync without being Clone

Signed-off-by: trivernis <trivernis@protonmail.com>
main
trivernis 3 years ago
parent 68102e4b8e
commit bdb5145fdb
Signed by: Trivernis
GPG Key ID: DFFFCC2C7A02DB45

@ -1,6 +1,6 @@
[package]
name = "trait-bound-typemap"
version = "0.3.2"
version = "0.3.3"
edition = "2021"
license = "Apache-2.0"
readme = "README.md"

@ -1,5 +1,6 @@
use crate::{
AnyTypeMap, CloneSendSyncTypeMap, CloneTypeMap, PartialEqTypeMap, TypeMap, TypeMapKey,
AnyTypeMap, CloneSendSyncTypeMap, CloneTypeMap, PartialEqTypeMap, SendSyncTypeMap, TypeMap,
TypeMapKey,
};
pub struct TestStructKey;
@ -98,6 +99,9 @@ fn it_converts() {
clone_send_sync_map.insert::<TestStructKey>(TestStruct::default());
assert!(clone_send_sync_map.contains_key::<TestStructKey>());
let send_sync_map = SendSyncTypeMap::from_iter(clone_send_sync_map.clone());
assert!(send_sync_map.contains_key::<TestStructKey>());
let clone_map = CloneTypeMap::from_iter(clone_send_sync_map);
assert!(clone_map.contains_key::<TestStructKey>());

@ -1,9 +1,11 @@
mod clone_send_sync_typemap;
mod clone_typemap;
mod partialeq_typemap;
mod send_sync_typemap;
mod typemap;
pub use clone_send_sync_typemap::*;
pub use clone_typemap::*;
pub use partialeq_typemap::*;
pub use send_sync_typemap::*;
pub use typemap::*;

@ -0,0 +1,14 @@
use crate::impl_typemap;
use std::any::Any;
impl_typemap!(
/// A typemap that is Send and Sync
SendSyncTypeMap,
SendSyncTypeMapKey,
Any,
Send,
Sync
);
unsafe impl Send for SendSyncTypeMap {}
unsafe impl Sync for SendSyncTypeMap {}
Loading…
Cancel
Save