use crate::{ Clear, Collection, CollectionMut, CollectionRef, Get, GetKeyValue, GetMut, Keyed, KeyedRef, Len, MapInsert, MapIter, MapIterMut, Remove, SimpleCollectionMut, SimpleCollectionRef, SimpleKeyedRef, }; use core::{borrow::Borrow, cmp::Ord, hash::Hash}; #[cfg(not(feature = "std"))] use alloc::string::String; impl Collection for serde_json::Map { type Item = serde_json::Value; } impl CollectionRef for serde_json::Map { type ItemRef<'a> = &'a serde_json::Value where Self: 'a; crate::covariant_item_ref!(); } impl CollectionMut for serde_json::Map { type ItemMut<'a> = &'a mut serde_json::Value where Self: 'a; crate::covariant_item_mut!(); } impl SimpleCollectionRef for serde_json::Map { crate::simple_collection_ref!(); } impl SimpleCollectionMut for serde_json::Map { fn into_mut<'a>(r: &'a mut serde_json::Value) -> &'a mut serde_json::Value where Self: 'a, { r } } impl Keyed for serde_json::Map { type Key = String; } impl KeyedRef for serde_json::Map { type KeyRef<'a> = &'a String where Self: 'a; crate::covariant_key_ref!(); } impl SimpleKeyedRef for serde_json::Map { crate::simple_keyed_ref!(); } impl Len for serde_json::Map { #[inline(always)] fn len(&self) -> usize { self.len() } #[inline(always)] fn is_empty(&self) -> bool { self.is_empty() } } impl MapIter for serde_json::Map { type Iter<'a> = serde_json::map::Iter<'a> where Self: 'a; #[inline(always)] fn iter(&self) -> Self::Iter<'_> { self.iter() } } impl MapIterMut for serde_json::Map { type IterMut<'a> = serde_json::map::IterMut<'a> where Self: 'a; #[inline(always)] fn iter_mut(&mut self) -> Self::IterMut<'_> { self.iter_mut() } } impl<'a, Q: ?Sized> Get<&'a Q> for serde_json::Map where String: Borrow, Q: Ord + Hash, { #[inline(always)] fn get(&self, q: &'a Q) -> Option<&serde_json::Value> { self.get(q) } } impl<'a, Q: ?Sized> GetMut<&'a Q> for serde_json::Map where String: Borrow, Q: Ord + Hash, { #[inline(always)] fn get_mut(&mut self, q: &'a Q) -> Option<&mut serde_json::Value> { self.get_mut(q) } } impl<'a, Q: ?Sized> GetKeyValue<&'a Q> for serde_json::Map where String: Borrow, Q: Ord + Hash, { #[inline(always)] #[deny(unconditional_recursion)] fn get_key_value(&self, q: &'a Q) -> Option<(&String, &serde_json::Value)> { self.get_key_value(q) } } impl MapInsert for serde_json::Map { type Output = Option; #[inline(always)] fn insert(&mut self, key: String, value: serde_json::Value) -> Option { self.insert(key, value) } } impl<'a, Q: ?Sized> Remove<&'a Q> for serde_json::Map where String: Borrow, Q: Ord + Hash, { #[inline(always)] fn remove(&mut self, key: &'a Q) -> Option { self.remove(key) } } impl Clear for serde_json::Map { #[inline(always)] fn clear(&mut self) { self.clear() } }