]> git.proxmox.com Git - rustc.git/blob - src/vendor/serde_json-0.9.10/src/map.rs
New upstream version 1.19.0+dfsg3
[rustc.git] / src / vendor / serde_json-0.9.10 / src / map.rs
1 //! A map of String to serde_json::Value.
2 //!
3 //! By default the map is backed by a BTreeMap. Enable the `preserve_order`
4 //! feature of serde_json to use LinkedHashMap instead.
5
6 use serde::{ser, de};
7 use std::fmt::{self, Debug};
8 use value::Value;
9 use std::hash::Hash;
10 use std::iter::FromIterator;
11 use std::borrow::Borrow;
12 use std::ops;
13
14 #[cfg(not(feature = "preserve_order"))]
15 use std::collections::{BTreeMap, btree_map};
16
17 #[cfg(feature = "preserve_order")]
18 use linked_hash_map::{self, LinkedHashMap};
19
20 /// Represents a JSON key/value type.
21 pub struct Map<K, V> {
22 map: MapImpl<K, V>,
23 }
24
25 #[cfg(not(feature = "preserve_order"))]
26 type MapImpl<K, V> = BTreeMap<K, V>;
27 #[cfg(feature = "preserve_order")]
28 type MapImpl<K, V> = LinkedHashMap<K, V>;
29
30 impl Map<String, Value> {
31 /// Makes a new empty Map.
32 #[inline]
33 pub fn new() -> Self {
34 Map {
35 map: MapImpl::new(),
36 }
37 }
38
39 #[cfg(not(feature = "preserve_order"))]
40 /// Makes a new empty Map with the given initial capacity.
41 #[inline]
42 pub fn with_capacity(capacity: usize) -> Self {
43 // does not support with_capacity
44 let _ = capacity;
45 Map {
46 map: BTreeMap::new(),
47 }
48 }
49
50 #[cfg(feature = "preserve_order")]
51 /// Makes a new empty Map with the given initial capacity.
52 #[inline]
53 pub fn with_capacity(capacity: usize) -> Self {
54 Map {
55 map: LinkedHashMap::with_capacity(capacity),
56 }
57 }
58
59 /// Clears the map, removing all values.
60 #[inline]
61 pub fn clear(&mut self) {
62 self.map.clear()
63 }
64
65 /// Returns a reference to the value corresponding to the key.
66 ///
67 /// The key may be any borrowed form of the map's key type, but the ordering
68 /// on the borrowed form *must* match the ordering on the key type.
69 #[inline]
70 pub fn get<Q: ?Sized>(&self, key: &Q) -> Option<&Value>
71 where String: Borrow<Q>,
72 Q: Ord + Eq + Hash
73 {
74 self.map.get(key)
75 }
76
77 /// Returns true if the map contains a value for the specified key.
78 ///
79 /// The key may be any borrowed form of the map's key type, but the ordering
80 /// on the borrowed form *must* match the ordering on the key type.
81 #[inline]
82 pub fn contains_key<Q: ?Sized>(&self, key: &Q) -> bool
83 where String: Borrow<Q>,
84 Q: Ord + Eq + Hash
85 {
86 self.map.contains_key(key)
87 }
88
89 /// Returns a mutable reference to the value corresponding to the key.
90 ///
91 /// The key may be any borrowed form of the map's key type, but the ordering
92 /// on the borrowed form *must* match the ordering on the key type.
93 #[inline]
94 pub fn get_mut<Q: ?Sized>(&mut self, key: &Q) -> Option<&mut Value>
95 where String: Borrow<Q>,
96 Q: Ord + Eq + Hash
97 {
98 self.map.get_mut(key)
99 }
100
101 /// Inserts a key-value pair into the map.
102 ///
103 /// If the map did not have this key present, `None` is returned.
104 ///
105 /// If the map did have this key present, the value is updated, and the old
106 /// value is returned. The key is not updated, though; this matters for
107 /// types that can be `==` without being identical.
108 #[inline]
109 pub fn insert(&mut self, k: String, v: Value) -> Option<Value> {
110 self.map.insert(k, v)
111 }
112
113 /// Removes a key from the map, returning the value at the key if the key
114 /// was previously in the map.
115 ///
116 /// The key may be any borrowed form of the map's key type, but the ordering
117 /// on the borrowed form *must* match the ordering on the key type.
118 #[inline]
119 pub fn remove<Q: ?Sized>(&mut self, key: &Q) -> Option<Value>
120 where String: Borrow<Q>,
121 Q: Ord + Eq + Hash
122 {
123 self.map.remove(key)
124 }
125
126 /// Gets the given key's corresponding entry in the map for in-place
127 /// manipulation.
128 pub fn entry<S>(&mut self, key: S) -> Entry
129 where S: Into<String>
130 {
131 #[cfg(not(feature = "preserve_order"))]
132 use std::collections::btree_map::Entry as EntryImpl;
133 #[cfg(feature = "preserve_order")]
134 use linked_hash_map::Entry as EntryImpl;
135
136 match self.map.entry(key.into()) {
137 EntryImpl::Vacant(vacant) => {
138 Entry::Vacant(VacantEntry { vacant: vacant })
139 }
140 EntryImpl::Occupied(occupied) => {
141 Entry::Occupied(OccupiedEntry { occupied: occupied })
142 }
143 }
144 }
145
146 /// Returns the number of elements in the map.
147 #[inline]
148 pub fn len(&self) -> usize {
149 self.map.len()
150 }
151
152 /// Returns true if the map contains no elements.
153 #[inline]
154 pub fn is_empty(&self) -> bool {
155 self.map.is_empty()
156 }
157
158 /// Gets an iterator over the entries of the map.
159 #[inline]
160 pub fn iter(&self) -> Iter {
161 Iter {
162 iter: self.map.iter(),
163 }
164 }
165
166 /// Gets a mutable iterator over the entries of the map.
167 #[inline]
168 pub fn iter_mut(&mut self) -> IterMut {
169 IterMut {
170 iter: self.map.iter_mut(),
171 }
172 }
173
174 /// Gets an iterator over the keys of the map.
175 #[inline]
176 pub fn keys(&self) -> Keys {
177 Keys {
178 iter: self.map.keys(),
179 }
180 }
181
182 /// Gets an iterator over the values of the map.
183 #[inline]
184 pub fn values(&self) -> Values {
185 Values {
186 iter: self.map.values(),
187 }
188 }
189 }
190
191 impl Default for Map<String, Value> {
192 #[inline]
193 fn default() -> Self {
194 Map {
195 map: MapImpl::new(),
196 }
197 }
198 }
199
200 impl Clone for Map<String, Value> {
201 #[inline]
202 fn clone(&self) -> Self {
203 Map {
204 map: self.map.clone(),
205 }
206 }
207 }
208
209 impl PartialEq for Map<String, Value> {
210 #[inline]
211 fn eq(&self, other: &Self) -> bool {
212 self.map.eq(&other.map)
213 }
214 }
215
216 /// Access an element of this map. Panics if the given key is not present in the
217 /// map.
218 ///
219 /// ```rust
220 /// # use serde_json::Value;
221 /// # let val = &Value::String("".to_owned());
222 /// # let _ =
223 /// match *val {
224 /// Value::String(ref s) => Some(s.as_str()),
225 /// Value::Array(ref arr) => arr[0].as_str(),
226 /// Value::Object(ref map) => map["type"].as_str(),
227 /// _ => None,
228 /// }
229 /// # ;
230 /// ```
231 impl<'a, Q: ?Sized> ops::Index<&'a Q> for Map<String, Value>
232 where String: Borrow<Q>,
233 Q: Ord + Eq + Hash
234 {
235 type Output = Value;
236
237 fn index(&self, index: &Q) -> &Value {
238 self.map.index(index)
239 }
240 }
241
242 /// Mutably access an element of this map. Panics if the given key is not
243 /// present in the map.
244 ///
245 /// ```rust
246 /// # #[macro_use] extern crate serde_json;
247 /// # fn main() {
248 /// # let mut map = serde_json::Map::new();
249 /// # map.insert("key".to_owned(), serde_json::Value::Null);
250 /// map["key"] = json!("value");
251 /// # }
252 /// ```
253 impl<'a, Q: ?Sized> ops::IndexMut<&'a Q> for Map<String, Value>
254 where String: Borrow<Q>,
255 Q: Ord + Eq + Hash
256 {
257 fn index_mut(&mut self, index: &Q) -> &mut Value {
258 self.map.get_mut(index).expect("no entry found for key")
259 }
260 }
261
262 impl Debug for Map<String, Value> {
263 #[inline]
264 fn fmt(&self, formatter: &mut fmt::Formatter) -> Result<(), fmt::Error> {
265 self.map.fmt(formatter)
266 }
267 }
268
269 impl ser::Serialize for Map<String, Value> {
270 #[inline]
271 fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
272 where S: ser::Serializer
273 {
274 use serde::ser::SerializeMap;
275 let mut map = try!(serializer.serialize_map(Some(self.len())));
276 for (k, v) in self {
277 try!(map.serialize_key(k));
278 try!(map.serialize_value(v));
279 }
280 map.end()
281 }
282 }
283
284 impl de::Deserialize for Map<String, Value> {
285 #[inline]
286 fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
287 where D: de::Deserializer
288 {
289 struct Visitor;
290
291 impl de::Visitor for Visitor {
292 type Value = Map<String, Value>;
293
294 fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
295 formatter.write_str("a map")
296 }
297
298 #[inline]
299 fn visit_unit<E>(self) -> Result<Self::Value, E>
300 where E: de::Error
301 {
302 Ok(Map::new())
303 }
304
305 #[inline]
306 fn visit_map<V>(self, mut visitor: V) -> Result<Self::Value, V::Error>
307 where V: de::MapVisitor
308 {
309 let mut values = Map::with_capacity(visitor.size_hint().0);
310
311 while let Some((key, value)) = try!(visitor.visit()) {
312 values.insert(key, value);
313 }
314
315 Ok(values)
316 }
317 }
318
319 deserializer.deserialize_map(Visitor)
320 }
321 }
322
323 impl FromIterator<(String, Value)> for Map<String, Value> {
324 fn from_iter<T>(iter: T) -> Self where T: IntoIterator<Item=(String, Value)> {
325 Map {
326 map: FromIterator::from_iter(iter)
327 }
328 }
329 }
330
331 impl Extend<(String, Value)> for Map<String, Value> {
332 fn extend<T>(&mut self, iter: T) where T: IntoIterator<Item=(String, Value)> {
333 self.map.extend(iter);
334 }
335 }
336
337 macro_rules! delegate_iterator {
338 (($name:ident $($generics:tt)*) => $item:ty) => {
339 impl $($generics)* Iterator for $name $($generics)* {
340 type Item = $item;
341 #[inline]
342 fn next(&mut self) -> Option<Self::Item> {
343 self.iter.next()
344 }
345 #[inline]
346 fn size_hint(&self) -> (usize, Option<usize>) {
347 self.iter.size_hint()
348 }
349 }
350
351 impl $($generics)* DoubleEndedIterator for $name $($generics)* {
352 #[inline]
353 fn next_back(&mut self) -> Option<Self::Item> {
354 self.iter.next_back()
355 }
356 }
357
358 impl $($generics)* ExactSizeIterator for $name $($generics)* {
359 #[inline]
360 fn len(&self) -> usize {
361 self.iter.len()
362 }
363 }
364 }
365 }
366
367 //////////////////////////////////////////////////////////////////////////////
368
369 /// A view into a single entry in a map, which may either be vacant or occupied.
370 /// This enum is constructed from the [`entry`] method on [`Map`].
371 ///
372 /// [`entry`]: struct.Map.html#method.entry
373 /// [`BTreeMap`]: struct.Map.html
374 pub enum Entry<'a> {
375 /// A vacant Entry.
376 Vacant(VacantEntry<'a>),
377 /// An occupied Entry.
378 Occupied(OccupiedEntry<'a>),
379 }
380
381 /// A vacant Entry. It is part of the [`Entry`] enum.
382 ///
383 /// [`Entry`]: enum.Entry.html
384 pub struct VacantEntry<'a> {
385 vacant: VacantEntryImpl<'a>,
386 }
387
388 /// An occupied Entry. It is part of the [`Entry`] enum.
389 ///
390 /// [`Entry`]: enum.Entry.html
391 pub struct OccupiedEntry<'a> {
392 occupied: OccupiedEntryImpl<'a>,
393 }
394
395 #[cfg(not(feature = "preserve_order"))]
396 type VacantEntryImpl<'a> = btree_map::VacantEntry<'a, String, Value>;
397 #[cfg(feature = "preserve_order")]
398 type VacantEntryImpl<'a> = linked_hash_map::VacantEntry<'a, String, Value>;
399
400 #[cfg(not(feature = "preserve_order"))]
401 type OccupiedEntryImpl<'a> = btree_map::OccupiedEntry<'a, String, Value>;
402 #[cfg(feature = "preserve_order")]
403 type OccupiedEntryImpl<'a> = linked_hash_map::OccupiedEntry<'a, String, Value>;
404
405 impl<'a> Entry<'a> {
406 /// Returns a reference to this entry's key.
407 ///
408 /// # Examples
409 ///
410 /// ```rust
411 /// let mut map = serde_json::Map::new();
412 /// assert_eq!(map.entry("serde").key(), &"serde");
413 /// ```
414 pub fn key(&self) -> &String {
415 match *self {
416 Entry::Vacant(ref e) => e.key(),
417 Entry::Occupied(ref e) => e.key(),
418 }
419 }
420
421 /// Ensures a value is in the entry by inserting the default if empty, and
422 /// returns a mutable reference to the value in the entry.
423 ///
424 /// # Examples
425 ///
426 /// ```rust
427 /// # #[macro_use] extern crate serde_json;
428 /// # fn main() {
429 /// let mut map = serde_json::Map::new();
430 /// map.entry("serde").or_insert(json!(12));
431 ///
432 /// assert_eq!(map["serde"], 12);
433 /// # }
434 /// ```
435 pub fn or_insert(self, default: Value) -> &'a mut Value {
436 match self {
437 Entry::Vacant(entry) => entry.insert(default.into()),
438 Entry::Occupied(entry) => entry.into_mut(),
439 }
440 }
441
442 /// Ensures a value is in the entry by inserting the result of the default
443 /// function if empty, and returns a mutable reference to the value in the
444 /// entry.
445 ///
446 /// # Examples
447 ///
448 /// ```rust
449 /// # #[macro_use] extern crate serde_json;
450 /// # fn main() {
451 /// let mut map = serde_json::Map::new();
452 /// map.entry("serde").or_insert_with(|| json!("hoho"));
453 ///
454 /// assert_eq!(map["serde"], "hoho".to_owned());
455 /// # }
456 /// ```
457 pub fn or_insert_with<F>(self, default: F) -> &'a mut Value
458 where F: FnOnce() -> Value
459 {
460 match self {
461 Entry::Vacant(entry) => entry.insert(default()),
462 Entry::Occupied(entry) => entry.into_mut(),
463 }
464 }
465 }
466
467 impl<'a> VacantEntry<'a> {
468 /// Gets a reference to the key that would be used when inserting a value
469 /// through the VacantEntry.
470 ///
471 /// # Examples
472 ///
473 /// ```rust
474 /// use serde_json::map::Entry;
475 ///
476 /// let mut map = serde_json::Map::new();
477 ///
478 /// match map.entry("serde") {
479 /// Entry::Vacant(vacant) => {
480 /// assert_eq!(vacant.key(), &"serde");
481 /// }
482 /// Entry::Occupied(_) => unimplemented!(),
483 /// }
484 /// ```
485 #[inline]
486 pub fn key(&self) -> &String {
487 self.vacant.key()
488 }
489
490 /// Sets the value of the entry with the VacantEntry's key, and returns a
491 /// mutable reference to it.
492 ///
493 /// # Examples
494 ///
495 /// ```rust
496 /// # #[macro_use] extern crate serde_json;
497 /// # fn main() {
498 /// use serde_json::map::Entry;
499 ///
500 /// let mut map = serde_json::Map::new();
501 ///
502 /// match map.entry("serde") {
503 /// Entry::Vacant(vacant) => {
504 /// vacant.insert(json!("hoho"));
505 /// }
506 /// Entry::Occupied(_) => unimplemented!(),
507 /// }
508 /// # }
509 /// ```
510 #[inline]
511 pub fn insert(self, value: Value) -> &'a mut Value {
512 self.vacant.insert(value.into())
513 }
514 }
515
516 impl<'a> OccupiedEntry<'a> {
517 /// Gets a reference to the key in the entry.
518 ///
519 /// # Examples
520 ///
521 /// ```rust
522 /// # #[macro_use] extern crate serde_json;
523 /// # fn main() {
524 /// use serde_json::map::Entry;
525 ///
526 /// let mut map = serde_json::Map::new();
527 /// map.insert("serde".to_owned(), json!(12));
528 ///
529 /// match map.entry("serde") {
530 /// Entry::Occupied(occupied) => {
531 /// assert_eq!(occupied.key(), &"serde");
532 /// }
533 /// Entry::Vacant(_) => unimplemented!(),
534 /// }
535 /// # }
536 /// ```
537 #[inline]
538 pub fn key(&self) -> &String {
539 self.occupied.key()
540 }
541
542 /// Gets a reference to the value in the entry.
543 ///
544 /// # Examples
545 ///
546 /// ```rust
547 /// # #[macro_use] extern crate serde_json;
548 /// # fn main() {
549 /// use serde_json::map::Entry;
550 ///
551 /// let mut map = serde_json::Map::new();
552 /// map.insert("serde".to_owned(), json!(12));
553 ///
554 /// match map.entry("serde") {
555 /// Entry::Occupied(occupied) => {
556 /// assert_eq!(occupied.get(), 12);
557 /// }
558 /// Entry::Vacant(_) => unimplemented!(),
559 /// }
560 /// # }
561 /// ```
562 #[inline]
563 pub fn get(&self) -> &Value {
564 self.occupied.get()
565 }
566
567 /// Gets a mutable reference to the value in the entry.
568 ///
569 /// # Examples
570 ///
571 /// ```rust
572 /// # #[macro_use] extern crate serde_json;
573 /// # fn main() {
574 /// use serde_json::map::Entry;
575 ///
576 /// let mut map = serde_json::Map::new();
577 /// map.insert("serde".to_owned(), json!([1, 2, 3]));
578 ///
579 /// match map.entry("serde") {
580 /// Entry::Occupied(mut occupied) => {
581 /// occupied.get_mut().as_array_mut().unwrap().push(json!(4));
582 /// }
583 /// Entry::Vacant(_) => unimplemented!(),
584 /// }
585 ///
586 /// assert_eq!(map["serde"].as_array().unwrap().len(), 4);
587 /// # }
588 /// ```
589 #[inline]
590 pub fn get_mut(&mut self) -> &mut Value {
591 self.occupied.get_mut()
592 }
593
594 /// Converts the entry into a mutable reference to its value.
595 ///
596 /// # Examples
597 ///
598 /// ```rust
599 /// # #[macro_use] extern crate serde_json;
600 /// # fn main() {
601 /// use serde_json::map::Entry;
602 ///
603 /// let mut map = serde_json::Map::new();
604 /// map.insert("serde".to_owned(), json!([1, 2, 3]));
605 ///
606 /// match map.entry("serde") {
607 /// Entry::Occupied(mut occupied) => {
608 /// occupied.into_mut().as_array_mut().unwrap().push(json!(4));
609 /// }
610 /// Entry::Vacant(_) => unimplemented!(),
611 /// }
612 ///
613 /// assert_eq!(map["serde"].as_array().unwrap().len(), 4);
614 /// # }
615 /// ```
616 #[inline]
617 pub fn into_mut(self) -> &'a mut Value {
618 self.occupied.into_mut()
619 }
620
621 /// Sets the value of the entry with the `OccupiedEntry`'s key, and returns
622 /// the entry's old value.
623 ///
624 /// # Examples
625 ///
626 /// ```rust
627 /// # #[macro_use] extern crate serde_json;
628 /// # fn main() {
629 /// use serde_json::map::Entry;
630 ///
631 /// let mut map = serde_json::Map::new();
632 /// map.insert("serde".to_owned(), json!(12));
633 ///
634 /// match map.entry("serde") {
635 /// Entry::Occupied(mut occupied) => {
636 /// assert_eq!(occupied.insert(json!(13)), 12);
637 /// assert_eq!(occupied.get(), 13);
638 /// }
639 /// Entry::Vacant(_) => unimplemented!(),
640 /// }
641 /// # }
642 /// ```
643 #[inline]
644 pub fn insert(&mut self, value: Value) -> Value {
645 self.occupied.insert(value.into())
646 }
647
648 /// Takes the value of the entry out of the map, and returns it.
649 ///
650 /// # Examples
651 ///
652 /// ```rust
653 /// # #[macro_use] extern crate serde_json;
654 /// # fn main() {
655 /// use serde_json::map::Entry;
656 ///
657 /// let mut map = serde_json::Map::new();
658 /// map.insert("serde".to_owned(), json!(12));
659 ///
660 /// match map.entry("serde") {
661 /// Entry::Occupied(occupied) => {
662 /// assert_eq!(occupied.remove(), 12);
663 /// }
664 /// Entry::Vacant(_) => unimplemented!(),
665 /// }
666 /// # }
667 /// ```
668 #[inline]
669 pub fn remove(self) -> Value {
670 self.occupied.remove()
671 }
672 }
673
674 //////////////////////////////////////////////////////////////////////////////
675
676 impl<'a> IntoIterator for &'a Map<String, Value> {
677 type Item = (&'a String, &'a Value);
678 type IntoIter = Iter<'a>;
679 #[inline]
680 fn into_iter(self) -> Self::IntoIter {
681 Iter {
682 iter: self.map.iter(),
683 }
684 }
685 }
686
687 /// An iterator over a serde_json::Map's entries.
688 pub struct Iter<'a> {
689 iter: IterImpl<'a>,
690 }
691
692 #[cfg(not(feature = "preserve_order"))]
693 type IterImpl<'a> = btree_map::Iter<'a, String, Value>;
694 #[cfg(feature = "preserve_order")]
695 type IterImpl<'a> = linked_hash_map::Iter<'a, String, Value>;
696
697 delegate_iterator!((Iter<'a>) => (&'a String, &'a Value));
698
699 //////////////////////////////////////////////////////////////////////////////
700
701 impl<'a> IntoIterator for &'a mut Map<String, Value> {
702 type Item = (&'a String, &'a mut Value);
703 type IntoIter = IterMut<'a>;
704 #[inline]
705 fn into_iter(self) -> Self::IntoIter {
706 IterMut {
707 iter: self.map.iter_mut(),
708 }
709 }
710 }
711
712 /// A mutable iterator over a serde_json::Map's entries.
713 pub struct IterMut<'a> {
714 iter: IterMutImpl<'a>,
715 }
716
717 #[cfg(not(feature = "preserve_order"))]
718 type IterMutImpl<'a> = btree_map::IterMut<'a, String, Value>;
719 #[cfg(feature = "preserve_order")]
720 type IterMutImpl<'a> = linked_hash_map::IterMut<'a, String, Value>;
721
722 delegate_iterator!((IterMut<'a>) => (&'a String, &'a mut Value));
723
724 //////////////////////////////////////////////////////////////////////////////
725
726 impl IntoIterator for Map<String, Value> {
727 type Item = (String, Value);
728 type IntoIter = IntoIter;
729 #[inline]
730 fn into_iter(self) -> Self::IntoIter {
731 IntoIter {
732 iter: self.map.into_iter(),
733 }
734 }
735 }
736
737 /// An owning iterator over a serde_json::Map's entries.
738 pub struct IntoIter {
739 iter: IntoIterImpl,
740 }
741
742 #[cfg(not(feature = "preserve_order"))]
743 type IntoIterImpl = btree_map::IntoIter<String, Value>;
744 #[cfg(feature = "preserve_order")]
745 type IntoIterImpl = linked_hash_map::IntoIter<String, Value>;
746
747 delegate_iterator!((IntoIter) => (String, Value));
748
749 //////////////////////////////////////////////////////////////////////////////
750
751 /// An iterator over a serde_json::Map's keys.
752 pub struct Keys<'a> {
753 iter: KeysImpl<'a>,
754 }
755
756 #[cfg(not(feature = "preserve_order"))]
757 type KeysImpl<'a> = btree_map::Keys<'a, String, Value>;
758 #[cfg(feature = "preserve_order")]
759 type KeysImpl<'a> = linked_hash_map::Keys<'a, String, Value>;
760
761 delegate_iterator!((Keys<'a>) => &'a String);
762
763 //////////////////////////////////////////////////////////////////////////////
764
765 /// An iterator over a serde_json::Map's values.
766 pub struct Values<'a> {
767 iter: ValuesImpl<'a>,
768 }
769
770 #[cfg(not(feature = "preserve_order"))]
771 type ValuesImpl<'a> = btree_map::Values<'a, String, Value>;
772 #[cfg(feature = "preserve_order")]
773 type ValuesImpl<'a> = linked_hash_map::Values<'a, String, Value>;
774
775 delegate_iterator!((Values<'a>) => &'a Value);