|
|
|
@ -11,6 +11,25 @@ use smallmap::{Collapse, Map};
|
|
|
|
|
#[cfg_attr(feature="serde", derive(serde::Serialize, serde::Deserialize))]
|
|
|
|
|
pub struct SmallRefMap<T: ?Sized>(Map<HashType, ()>, PhantomData<Map<*const T, ()>>);
|
|
|
|
|
|
|
|
|
|
#[cfg(test)]
|
|
|
|
|
#[cfg(feature="serde")]
|
|
|
|
|
mod serde_tests
|
|
|
|
|
{
|
|
|
|
|
use super::*;
|
|
|
|
|
#[test]
|
|
|
|
|
fn ser_de()
|
|
|
|
|
{
|
|
|
|
|
let mut rmap = SmallRefMap::new();
|
|
|
|
|
rmap.insert("hello");
|
|
|
|
|
|
|
|
|
|
let string = serde_json::to_string(&rmap).expect("Ser failed");
|
|
|
|
|
println!("String {:?}", string);
|
|
|
|
|
let rmap2 = serde_json::from_str(&string[..]).expect("De failed)");
|
|
|
|
|
assert_eq!(rmap, rmap2);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
unsafe impl<T: ?Sized + Send> Send for SmallRefMap<T>{}
|
|
|
|
|
unsafe impl<T: ?Sized + Send + Sync> Sync for SmallRefMap<T>{}
|
|
|
|
|
|
|
|
|
|