diff --git a/merde_json/src/lib.rs b/merde_json/src/lib.rs index 57525a5..9576670 100644 --- a/merde_json/src/lib.rs +++ b/merde_json/src/lib.rs @@ -966,6 +966,50 @@ impl ToStatic for Option { } } +impl ToStatic for Vec { + type Output = Vec; + + fn to_static(&self) -> Self::Output { + self.iter().map(|v| v.to_static()).collect() + } +} + +impl ToStatic for HashMap +where + K: ToStatic + Eq + Hash, + V: ToStatic, + K::Output: Eq + Hash, +{ + type Output = HashMap; + + fn to_static(&self) -> Self::Output { + self.iter() + .map(|(k, v)| (k.to_static(), v.to_static())) + .collect() + } +} + +use std::collections::{HashSet, VecDeque}; + +impl ToStatic for HashSet +where + T::Output: Eq + Hash, +{ + type Output = HashSet; + + fn to_static(&self) -> Self::Output { + self.iter().map(|v| v.to_static()).collect() + } +} + +impl ToStatic for VecDeque { + type Output = VecDeque; + + fn to_static(&self) -> Self::Output { + self.iter().map(|v| v.to_static()).collect() + } +} + /// Extension trait to provide `to_rust_value` on `JsonValue<'_>` /// /// Which allows you to do something like: