From 2a320b05a867865fab93da73ee5c40485dd4f1f8 Mon Sep 17 00:00:00 2001 From: Avril Date: Thu, 22 Oct 2020 02:54:23 +0100 Subject: [PATCH] added smallmap feature --- Cargo.toml | 6 ++---- src/small.rs | 19 +++++++++++++++++++ 2 files changed, 21 insertions(+), 4 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index c0ea79a..68f6555 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -3,19 +3,17 @@ name = "refset" description = "A non-owning HashSet" repository = "https://git.flanchan.moe/flanchan/refset" keywords = ["hash", "set", "reference"] -version = "0.1.1" +version = "0.2.0" authors = ["Avril "] edition = "2018" license= "MIT" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html -[features] - [dependencies] sha2 = "0.9" serde = {version = "1.0", optional = true, features=["derive"]} -smallmap = {version = "1.1", optional = true} # serde here is kinda broken for now +smallmap = {version = "1.1.6", optional = true, features= ["serde"]} [dev-dependencies] serde_json = "1.0" diff --git a/src/small.rs b/src/small.rs index daf5a39..e6c6da3 100644 --- a/src/small.rs +++ b/src/small.rs @@ -11,6 +11,25 @@ use smallmap::{Collapse, Map}; #[cfg_attr(feature="serde", derive(serde::Serialize, serde::Deserialize))] pub struct SmallRefMap(Map, PhantomData>); +#[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 Send for SmallRefMap{} unsafe impl Sync for SmallRefMap{}