Debian Codegraph @

src/impls/serde_json.rs

raw symbols ◀ ▶ SCIP
1 Debian patch touch this file
1 use crate::{
2 Clear, Collection, CollectionMut, CollectionRef, Get, GetKeyValue, GetMut, Keyed, KeyedRef,
3 Len, MapInsert, MapIter, MapIterMut, Remove, SimpleCollectionMut, SimpleCollectionRef,
4 SimpleKeyedRef,
5 };
•6 use core::{borrow::Borrow, cmp::Ord, hash::Hash};
7
8 #[cfg(not(feature = "std"))]
9 use alloc::string::String;
10
11 impl Collection for serde_json::Map<String, serde_json::Value> {
12 type Item = serde_json::Value;
13 }
14
15 impl CollectionRef for serde_json::Map<String, serde_json::Value> {
16 type ItemRef<'a> = &'a serde_json::Value where Self: 'a;
17
18 crate::covariant_item_ref!();
19 }
20
21 impl CollectionMut for serde_json::Map<String, serde_json::Value> {
22 type ItemMut<'a> = &'a mut serde_json::Value where Self: 'a;
23
24 crate::covariant_item_mut!();
25 }
26
27 impl SimpleCollectionRef for serde_json::Map<String, serde_json::Value> {
28 crate::simple_collection_ref!();
29 }
30
31 impl SimpleCollectionMut for serde_json::Map<String, serde_json::Value> {
32 fn into_mut<'a>(r: &'a mut serde_json::Value) -> &'a mut serde_json::Value
33 where
34 Self: 'a,
35 {
36 r
37 }
38 }
39
40 impl Keyed for serde_json::Map<String, serde_json::Value> {
41 type Key = String;
42 }
43
44 impl KeyedRef for serde_json::Map<String, serde_json::Value> {
45 type KeyRef<'a> = &'a String where Self: 'a;
46
47 crate::covariant_key_ref!();
48 }
49
50 impl SimpleKeyedRef for serde_json::Map<String, serde_json::Value> {
51 crate::simple_keyed_ref!();
52 }
53
54 impl Len for serde_json::Map<String, serde_json::Value> {
55 #[inline(always)]
56 fn len(&self) -> usize {
57 self.len()
58 }
59
60 #[inline(always)]
61 fn is_empty(&self) -> bool {
62 self.is_empty()
63 }
64 }
65
66 impl MapIter for serde_json::Map<String, serde_json::Value> {
67 type Iter<'a> = serde_json::map::Iter<'a> where Self: 'a;
68
69 #[inline(always)]
70 fn iter(&self) -> Self::Iter<'_> {
71 self.iter()
72 }
73 }
74
75 impl MapIterMut for serde_json::Map<String, serde_json::Value> {
76 type IterMut<'a> = serde_json::map::IterMut<'a> where Self: 'a;
77
78 #[inline(always)]
79 fn iter_mut(&mut self) -> Self::IterMut<'_> {
80 self.iter_mut()
81 }
82 }
83
84 impl<'a, Q: ?Sized> Get<&'a Q> for serde_json::Map<String, serde_json::Value>
85 where
86 String: Borrow<Q>,
87 Q: Ord + Hash,
88 {
89 #[inline(always)]
90 fn get(&self, q: &'a Q) -> Option<&serde_json::Value> {
91 self.get(q)
92 }
93 }
94
95 impl<'a, Q: ?Sized> GetMut<&'a Q> for serde_json::Map<String, serde_json::Value>
96 where
97 String: Borrow<Q>,
98 Q: Ord + Hash,
99 {
100 #[inline(always)]
101 fn get_mut(&mut self, q: &'a Q) -> Option<&mut serde_json::Value> {
102 self.get_mut(q)
103 }
104 }
105
106 impl<'a, Q: ?Sized> GetKeyValue<&'a Q> for serde_json::Map<String, serde_json::Value>
107 where
108 String: Borrow<Q>,
109 Q: Ord + Hash,
110 {
111 #[inline(always)]
112 #[deny(unconditional_recursion)]
113 fn get_key_value(&self, q: &'a Q) -> Option<(&String, &serde_json::Value)> {
114 self.get_key_value(q)
115 }
116 }
117
118 impl MapInsert<String> for serde_json::Map<String, serde_json::Value> {
119 type Output = Option<serde_json::Value>;
120
121 #[inline(always)]
122 fn insert(&mut self, key: String, value: serde_json::Value) -> Option<serde_json::Value> {
123 self.insert(key, value)
124 }
125 }
126
127 impl<'a, Q: ?Sized> Remove<&'a Q> for serde_json::Map<String, serde_json::Value>
128 where
129 String: Borrow<Q>,
130 Q: Ord + Hash,
131 {
132 #[inline(always)]
133 fn remove(&mut self, key: &'a Q) -> Option<serde_json::Value> {
134 self.remove(key)
135 }
136 }
137
138 impl Clear for serde_json::Map<String, serde_json::Value> {
139 #[inline(always)]
140 fn clear(&mut self) {
141 self.clear()
142 }
143 }