Debian Codegraph @

src/impls/std/hashset.rs

raw symbols SCIP
1 use crate::{
2 Clear, Collection, CollectionMut, CollectionRef, Get, Insert, Iter, Len, Remove,
3 SimpleCollectionMut, SimpleCollectionRef,
4 };
5 use std::{borrow::Borrow, collections::HashSet, hash::Hash};
6
7 impl<T> Collection for HashSet<T> {
8 type Item = T;
9 }
10
11 impl<T> CollectionRef for HashSet<T> {
12 type ItemRef<'a> = &'a T where Self: 'a;
13
14 crate::covariant_item_ref!();
15 }
16
17 impl<T> CollectionMut for HashSet<T> {
18 type ItemMut<'a> = &'a mut T where Self: 'a;
19
20 crate::covariant_item_mut!();
21 }
22
23 impl<T> SimpleCollectionRef for HashSet<T> {
24 crate::simple_collection_ref!();
25 }
26
27 impl<T> SimpleCollectionMut for HashSet<T> {
28 crate::simple_collection_mut!();
29 }
30
31 impl<T> Len for HashSet<T> {
32 #[inline(always)]
33 fn len(&self) -> usize {
34 self.len()
35 }
36
37 #[inline(always)]
38 fn is_empty(&self) -> bool {
39 self.is_empty()
40 }
41 }
42
43 impl<'a, Q, T: Hash + Eq> Get<&'a Q> for HashSet<T>
44 where
45 T: Borrow<Q>,
46 Q: Hash + Eq + ?Sized,
47 {
48 fn get(&self, value: &'a Q) -> Option<&T> {
49 self.get(value)
50 }
51 }
52
53 impl<T: Hash + Eq> Insert for HashSet<T> {
54 type Output = bool;
55
56 #[inline(always)]
57 fn insert(&mut self, t: T) -> bool {
58 self.insert(t)
59 }
60 }
61
62 impl<'a, Q, T: Hash + Eq> Remove<&'a Q> for HashSet<T>
63 where
64 T: Borrow<Q>,
65 Q: Hash + Eq + ?Sized,
66 {
67 #[inline(always)]
68 fn remove(&mut self, t: &'a Q) -> Option<T> {
69 self.take(t)
70 }
71 }
72
73 impl<T: Hash + Eq> Clear for HashSet<T> {
74 #[inline(always)]
75 fn clear(&mut self) {
76 self.clear()
77 }
78 }
79
80 impl<T> Iter for HashSet<T> {
81 type Iter<'a> = std::collections::hash_set::Iter<'a, T> where Self: 'a;
82
83 #[inline(always)]
84 fn iter(&self) -> Self::Iter<'_> {
85 self.iter()
86 }
87 }