Skip to content

Commit d48c224

Browse files
committed
Add Map::into_values method
Signed-off-by: tison <wander4096@gmail.com>
1 parent 1e77cac commit d48c224

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

src/map.rs

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -338,6 +338,14 @@ impl Map<String, Value> {
338338
}
339339
}
340340

341+
/// Gets an iterator over the values of the map.
342+
#[inline]
343+
pub fn into_values(self) -> IntoValues {
344+
IntoValues {
345+
iter: self.map.into_values(),
346+
}
347+
}
348+
341349
/// Retains only the elements specified by the predicate.
342350
///
343351
/// In other words, remove all pairs `(k, v)` such that `f(&k, &mut v)`
@@ -1155,3 +1163,17 @@ type ValuesMutImpl<'a> = btree_map::ValuesMut<'a, String, Value>;
11551163
type ValuesMutImpl<'a> = indexmap::map::ValuesMut<'a, String, Value>;
11561164

11571165
delegate_iterator!((ValuesMut<'a>) => &'a mut Value);
1166+
1167+
//////////////////////////////////////////////////////////////////////////////
1168+
1169+
/// An owning iterator over a serde_json::Map's values.
1170+
pub struct IntoValues {
1171+
iter: IntoValuesImpl,
1172+
}
1173+
1174+
#[cfg(not(feature = "preserve_order"))]
1175+
type IntoValuesImpl = btree_map::IntoValues<String, Value>;
1176+
#[cfg(feature = "preserve_order")]
1177+
type IntoValuesImpl = indexmap::map::IntoValues<String, Value>;
1178+
1179+
delegate_iterator!((IntoValues) => Value);

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy