1
+ //! A fixed-capacity hash set where the iteration order is independent of the hash values.
1
2
use core:: {
2
3
borrow:: Borrow ,
3
4
fmt,
@@ -15,7 +16,7 @@ use crate::index_map::{self, IndexMap};
15
16
///
16
17
/// # Examples
17
18
/// ```
18
- /// use heapless::FnvIndexSet;
19
+ /// use heapless::index_set:: FnvIndexSet;
19
20
///
20
21
/// // A hash set with a capacity of 16 elements allocated on the stack
21
22
/// let mut books = FnvIndexSet::<_, 16>::new();
@@ -57,7 +58,7 @@ pub type FnvIndexSet<T, const N: usize> = IndexSet<T, BuildHasherDefault<FnvHash
57
58
/// for this example.
58
59
///
59
60
/// ```
60
- /// use heapless::FnvIndexSet;
61
+ /// use heapless::index_set:: FnvIndexSet;
61
62
///
62
63
/// // A hash set with a capacity of 16 elements allocated on the stack
63
64
/// let mut books = FnvIndexSet::<_, 16>::new();
@@ -103,7 +104,7 @@ impl<T, S, const N: usize> IndexSet<T, S, N> {
103
104
/// # Examples
104
105
///
105
106
/// ```
106
- /// use heapless::FnvIndexSet;
107
+ /// use heapless::index_set:: FnvIndexSet;
107
108
///
108
109
/// let set = FnvIndexSet::<i32, 16>::new();
109
110
/// assert_eq!(set.capacity(), 16);
@@ -117,7 +118,7 @@ impl<T, S, const N: usize> IndexSet<T, S, N> {
117
118
/// # Examples
118
119
///
119
120
/// ```
120
- /// use heapless::FnvIndexSet;
121
+ /// use heapless::index_set:: FnvIndexSet;
121
122
///
122
123
/// let mut set = FnvIndexSet::<_, 16>::new();
123
124
/// set.insert("a").unwrap();
@@ -153,7 +154,7 @@ impl<T, S, const N: usize> IndexSet<T, S, N> {
153
154
/// # Examples
154
155
///
155
156
/// ```
156
- /// use heapless::FnvIndexSet;
157
+ /// use heapless::index_set:: FnvIndexSet;
157
158
///
158
159
/// let mut v: FnvIndexSet<_, 16> = FnvIndexSet::new();
159
160
/// assert_eq!(v.len(), 0);
@@ -169,7 +170,7 @@ impl<T, S, const N: usize> IndexSet<T, S, N> {
169
170
/// # Examples
170
171
///
171
172
/// ```
172
- /// use heapless::FnvIndexSet;
173
+ /// use heapless::index_set:: FnvIndexSet;
173
174
///
174
175
/// let mut v: FnvIndexSet<_, 16> = FnvIndexSet::new();
175
176
/// assert!(v.is_empty());
@@ -185,7 +186,7 @@ impl<T, S, const N: usize> IndexSet<T, S, N> {
185
186
/// # Examples
186
187
///
187
188
/// ```
188
- /// use heapless::FnvIndexSet;
189
+ /// use heapless::index_set:: FnvIndexSet;
189
190
///
190
191
/// let mut v: FnvIndexSet<_, 4> = FnvIndexSet::new();
191
192
/// assert!(!v.is_full());
@@ -204,7 +205,7 @@ impl<T, S, const N: usize> IndexSet<T, S, N> {
204
205
/// # Examples
205
206
///
206
207
/// ```
207
- /// use heapless::FnvIndexSet;
208
+ /// use heapless::index_set:: FnvIndexSet;
208
209
///
209
210
/// let mut v: FnvIndexSet<_, 16> = FnvIndexSet::new();
210
211
/// v.insert(1).unwrap();
@@ -227,7 +228,7 @@ where
227
228
/// # Examples
228
229
///
229
230
/// ```
230
- /// use heapless::FnvIndexSet;
231
+ /// use heapless::index_set:: FnvIndexSet;
231
232
///
232
233
/// let mut a: FnvIndexSet<_, 16> = [1, 2, 3].iter().cloned().collect();
233
234
/// let mut b: FnvIndexSet<_, 16> = [4, 2, 3, 4].iter().cloned().collect();
@@ -264,7 +265,7 @@ where
264
265
/// # Examples
265
266
///
266
267
/// ```
267
- /// use heapless::FnvIndexSet;
268
+ /// use heapless::index_set:: FnvIndexSet;
268
269
///
269
270
/// let mut a: FnvIndexSet<_, 16> = [1, 2, 3].iter().cloned().collect();
270
271
/// let mut b: FnvIndexSet<_, 16> = [4, 2, 3, 4].iter().cloned().collect();
@@ -296,7 +297,7 @@ where
296
297
/// # Examples
297
298
///
298
299
/// ```
299
- /// use heapless::FnvIndexSet;
300
+ /// use heapless::index_set:: FnvIndexSet;
300
301
///
301
302
/// let mut a: FnvIndexSet<_, 16> = [1, 2, 3].iter().cloned().collect();
302
303
/// let mut b: FnvIndexSet<_, 16> = [4, 2, 3, 4].iter().cloned().collect();
@@ -328,7 +329,7 @@ where
328
329
/// # Examples
329
330
///
330
331
/// ```
331
- /// use heapless::FnvIndexSet;
332
+ /// use heapless::index_set:: FnvIndexSet;
332
333
///
333
334
/// let mut a: FnvIndexSet<_, 16> = [1, 2, 3].iter().cloned().collect();
334
335
/// let mut b: FnvIndexSet<_, 16> = [4, 2, 3, 4].iter().cloned().collect();
@@ -359,7 +360,7 @@ where
359
360
/// # Examples
360
361
///
361
362
/// ```
362
- /// use heapless::FnvIndexSet;
363
+ /// use heapless::index_set:: FnvIndexSet;
363
364
///
364
365
/// let set: FnvIndexSet<_, 16> = [1, 2, 3].iter().cloned().collect();
365
366
/// assert_eq!(set.contains(&1), true);
@@ -379,7 +380,7 @@ where
379
380
/// # Examples
380
381
///
381
382
/// ```
382
- /// use heapless::FnvIndexSet;
383
+ /// use heapless::index_set:: FnvIndexSet;
383
384
///
384
385
/// let a: FnvIndexSet<_, 16> = [1, 2, 3].iter().cloned().collect();
385
386
/// let mut b = FnvIndexSet::<_, 16>::new();
@@ -403,7 +404,7 @@ where
403
404
/// # Examples
404
405
///
405
406
/// ```
406
- /// use heapless::FnvIndexSet;
407
+ /// use heapless::index_set:: FnvIndexSet;
407
408
///
408
409
/// let sup: FnvIndexSet<_, 16> = [1, 2, 3].iter().cloned().collect();
409
410
/// let mut set = FnvIndexSet::<_, 16>::new();
@@ -427,7 +428,7 @@ where
427
428
/// # Examples
428
429
///
429
430
/// ```
430
- /// use heapless::FnvIndexSet;
431
+ /// use heapless::index_set:: FnvIndexSet;
431
432
///
432
433
/// let sub: FnvIndexSet<_, 16> = [1, 2].iter().cloned().collect();
433
434
/// let mut set = FnvIndexSet::<_, 16>::new();
@@ -457,7 +458,7 @@ where
457
458
/// # Examples
458
459
///
459
460
/// ```
460
- /// use heapless::FnvIndexSet;
461
+ /// use heapless::index_set:: FnvIndexSet;
461
462
///
462
463
/// let mut set = FnvIndexSet::<_, 16>::new();
463
464
///
@@ -480,7 +481,7 @@ where
480
481
/// # Examples
481
482
///
482
483
/// ```
483
- /// use heapless::FnvIndexSet;
484
+ /// use heapless::index_set:: FnvIndexSet;
484
485
///
485
486
/// let mut set = FnvIndexSet::<_, 16>::new();
486
487
///
@@ -629,6 +630,9 @@ impl<T> Clone for Iter<'_, T> {
629
630
}
630
631
}
631
632
633
+ /// An iterator over the difference of two `IndexSet`s.
634
+ ///
635
+ /// This is created by the [`IndexSet::difference`] method.
632
636
pub struct Difference < ' a , T , S , const N : usize >
633
637
where
634
638
S : BuildHasher ,
@@ -655,6 +659,9 @@ where
655
659
}
656
660
}
657
661
662
+ /// An iterator over the intersection of two `IndexSet`s.
663
+ ///
664
+ /// This is created by the [`IndexSet::intersection`] method.
658
665
pub struct Intersection < ' a , T , S , const N : usize >
659
666
where
660
667
S : BuildHasher ,
0 commit comments