1
0
Fork 0
forked from wry/wry

all: add HashMapExt

This commit is contained in:
Julian Orth 2024-05-08 15:13:21 +02:00
parent 4c0e6d9b51
commit 0d7a07ec40
29 changed files with 99 additions and 69 deletions

15
src/utils/hash_map_ext.rs Normal file
View 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)
}
}