From d8a737e9884eb062b75c67b99f9b9d598bd7f29d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A9o=20Gaspard?= Date: Wed, 1 Feb 2023 20:50:43 +0100 Subject: [PATCH] Expose values_mut, similar to std::collections::HashMap::values_mut --- src/hash/map.rs | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/hash/map.rs b/src/hash/map.rs index 4bbba40..b6528b6 100644 --- a/src/hash/map.rs +++ b/src/hash/map.rs @@ -337,6 +337,19 @@ impl HashMap { } } + /// Get a mutable iterator over a hash map's values. + /// + /// Please note that the order is consistent between maps using + /// the same hasher, but no other ordering guarantee is offered. + /// Items will not come out in insertion order or sort order. + /// They will, however, come out in the same order every time for + /// the same map. + #[inline] + #[must_use] + pub fn values_mut(&mut self) -> impl Iterator { + self.iter_mut().map(|(_, v)| v) + } + /// Discard all elements from the map. /// /// This leaves you with an empty map, and all elements that