Change Set::insert type

This commit is contained in:
Shunsuke Shibayama 2022-09-13 02:36:18 +09:00
parent 2606638253
commit 2fdc881a2e
2 changed files with 7 additions and 2 deletions

View file

@ -118,3 +118,8 @@ where
} }
Ok(v) Ok(v)
} }
pub fn unique_in_place<T: Eq + std::hash::Hash + Clone>(v: &mut Vec<T>) {
let mut uniques = Set::new();
v.retain(|e| uniques.insert(e.clone()));
}

View file

@ -141,8 +141,8 @@ impl<T: Hash + Eq> Set<T> {
} }
#[inline] #[inline]
pub fn insert(&mut self, value: T) { pub fn insert(&mut self, value: T) -> bool {
self.elems.insert(value); self.elems.insert(value)
} }
#[inline] #[inline]