all: add HashMapExt
This commit is contained in:
parent
4c0e6d9b51
commit
0d7a07ec40
29 changed files with 99 additions and 69 deletions
15
src/utils/hash_map_ext.rs
Normal file
15
src/utils/hash_map_ext.rs
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
use std::collections::HashMap;
|
||||
|
||||
pub trait HashMapExt {
|
||||
type V;
|
||||
|
||||
fn drain_values(&mut self) -> impl Iterator<Item = Self::V>;
|
||||
}
|
||||
|
||||
impl<K, V, S> HashMapExt for HashMap<K, V, S> {
|
||||
type V = V;
|
||||
|
||||
fn drain_values(&mut self) -> impl Iterator<Item = Self::V> {
|
||||
self.drain().map(|(_, v)| v)
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue