Skip to content

Commit b97935f

Browse files
authored
Merge pull request #1226 from tisonkun/map-into-values
Add Map::into_values method
2 parents 1e77cac + d48c224 commit b97935f

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

src/map.rs

+22
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)