Coverage Report

Created: 2026-04-09 08:09

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/wasm-tools/crates/wasmparser/src/collections/set.rs
Line
Count
Source
1
//! Type definitions for a default set.
2
3
use core::{
4
    borrow::Borrow,
5
    fmt::{self, Debug},
6
    hash::Hash,
7
    iter::FusedIterator,
8
    ops::{BitAnd, BitOr, BitXor, Sub},
9
};
10
11
#[cfg(all(
12
    feature = "hash-collections",
13
    not(feature = "prefer-btree-collections")
14
))]
15
mod detail {
16
    use crate::collections::hash;
17
    use hashbrown::hash_set;
18
19
    pub type SetImpl<T> = hash_set::HashSet<T, hash::RandomState>;
20
    pub type IterImpl<'a, T> = hash_set::Iter<'a, T>;
21
    pub type IntoIterImpl<T> = hash_set::IntoIter<T>;
22
    pub type DifferenceImpl<'a, T> = hash_set::Difference<'a, T, hash::RandomState>;
23
    pub type IntersectionImpl<'a, T> = hash_set::Intersection<'a, T, hash::RandomState>;
24
    pub type SymmetricDifferenceImpl<'a, T> =
25
        hash_set::SymmetricDifference<'a, T, hash::RandomState>;
26
    pub type UnionImpl<'a, T> = hash_set::Union<'a, T, hash::RandomState>;
27
}
28
29
#[cfg(any(
30
    not(feature = "hash-collections"),
31
    feature = "prefer-btree-collections"
32
))]
33
mod detail {
34
    use alloc::collections::btree_set;
35
36
    pub type SetImpl<T> = btree_set::BTreeSet<T>;
37
    pub type IterImpl<'a, T> = btree_set::Iter<'a, T>;
38
    pub type IntoIterImpl<T> = btree_set::IntoIter<T>;
39
    pub type DifferenceImpl<'a, T> = btree_set::Difference<'a, T>;
40
    pub type IntersectionImpl<'a, T> = btree_set::Intersection<'a, T>;
41
    pub type SymmetricDifferenceImpl<'a, T> = btree_set::SymmetricDifference<'a, T>;
42
    pub type UnionImpl<'a, T> = btree_set::Union<'a, T>;
43
}
44
45
/// A default set of values.
46
///
47
/// Provides an API compatible with both [`HashSet`] and [`BTreeSet`].
48
///
49
/// [`HashSet`]: hashbrown::HashSet
50
/// [`BTreeSet`]: alloc::collections::BTreeSet
51
#[derive(Debug, Clone)]
52
pub struct Set<T> {
53
    /// The underlying hash-set or btree-set data structure used.
54
    inner: detail::SetImpl<T>,
55
}
56
57
impl<T> Default for Set<T> {
58
    #[inline]
59
488k
    fn default() -> Self {
60
488k
        Self {
61
488k
            inner: detail::SetImpl::default(),
62
488k
        }
63
488k
    }
<wasmparser::collections::set::Set<wasmparser::validator::component_types::ComponentAnyTypeId> as core::default::Default>::default
Line
Count
Source
59
368k
    fn default() -> Self {
60
368k
        Self {
61
368k
            inner: detail::SetImpl::default(),
62
368k
        }
63
368k
    }
<wasmparser::collections::set::Set<&wasmparser::validator::names::KebabStr> as core::default::Default>::default
Line
Count
Source
59
27.2k
    fn default() -> Self {
60
27.2k
        Self {
61
27.2k
            inner: detail::SetImpl::default(),
62
27.2k
        }
63
27.2k
    }
<wasmparser::collections::set::Set<u32> as core::default::Default>::default
Line
Count
Source
59
93.4k
    fn default() -> Self {
60
93.4k
        Self {
61
93.4k
            inner: detail::SetImpl::default(),
62
93.4k
        }
63
93.4k
    }
64
}
65
66
impl<T> Set<T> {
67
    /// Clears the [`Set`], removing all elements.
68
    #[inline]
69
27.2k
    pub fn clear(&mut self) {
70
27.2k
        self.inner.clear()
71
27.2k
    }
72
73
    /// Retains only the elements specified by the predicate.
74
    ///
75
    /// In other words, remove all elements `e` for which `f(&e)` returns `false`.
76
    /// The elements are visited in unsorted (and unspecified) order.
77
    #[inline]
78
0
    pub fn retain<F>(&mut self, f: F)
79
0
    where
80
0
        T: Ord,
81
0
        F: FnMut(&T) -> bool,
82
    {
83
0
        self.inner.retain(f)
84
0
    }
85
86
    /// Returns the number of elements in the [`Set`].
87
    #[inline]
88
0
    pub fn len(&self) -> usize {
89
0
        self.inner.len()
90
0
    }
91
92
    /// Returns `true` if the [`Set`] contains no elements.
93
    #[inline]
94
0
    pub fn is_empty(&self) -> bool {
95
0
        self.inner.is_empty()
96
0
    }
97
98
    /// Returns an iterator that yields the items in the [`Set`].
99
    #[inline]
100
0
    pub fn iter(&self) -> Iter<'_, T> {
101
0
        Iter {
102
0
            inner: self.inner.iter(),
103
0
        }
104
0
    }
105
}
106
107
impl<T> Set<T>
108
where
109
    T: Eq + Hash + Ord,
110
{
111
    /// Reserves capacity for at least `additional` more elements to be inserted in the [`Set`].
112
    #[inline]
113
27.2k
    pub fn reserve(&mut self, additional: usize) {
114
        #[cfg(all(
115
            feature = "hash-collections",
116
            not(feature = "prefer-btree-collections")
117
        ))]
118
27.2k
        self.inner.reserve(additional);
119
        #[cfg(any(
120
            not(feature = "hash-collections"),
121
            feature = "prefer-btree-collections"
122
        ))]
123
        let _ = additional;
124
27.2k
    }
125
126
    /// Returns true if the [`Set`] contains an element equal to the `value`.
127
    #[inline]
128
31.9k
    pub fn contains<Q>(&self, value: &Q) -> bool
129
31.9k
    where
130
31.9k
        T: Borrow<Q>,
131
31.9k
        Q: ?Sized + Hash + Eq + Ord,
132
    {
133
31.9k
        self.inner.contains(value)
134
31.9k
    }
<wasmparser::collections::set::Set<wasmparser::validator::component_types::ComponentAnyTypeId>>::contains::<wasmparser::validator::component_types::ComponentAnyTypeId>
Line
Count
Source
128
10.2k
    pub fn contains<Q>(&self, value: &Q) -> bool
129
10.2k
    where
130
10.2k
        T: Borrow<Q>,
131
10.2k
        Q: ?Sized + Hash + Eq + Ord,
132
    {
133
10.2k
        self.inner.contains(value)
134
10.2k
    }
<wasmparser::collections::set::Set<u32>>::contains::<u32>
Line
Count
Source
128
21.6k
    pub fn contains<Q>(&self, value: &Q) -> bool
129
21.6k
    where
130
21.6k
        T: Borrow<Q>,
131
21.6k
        Q: ?Sized + Hash + Eq + Ord,
132
    {
133
21.6k
        self.inner.contains(value)
134
21.6k
    }
135
136
    /// Returns a reference to the element in the [`Set`], if any, that is equal to the `value`.
137
    #[inline]
138
0
    pub fn get<Q>(&self, value: &Q) -> Option<&T>
139
0
    where
140
0
        T: Borrow<Q>,
141
0
        Q: ?Sized + Hash + Eq + Ord,
142
    {
143
0
        self.inner.get(value)
144
0
    }
145
146
    /// Adds `value` to the [`Set`].
147
    ///
148
    /// Returns whether the value was newly inserted:
149
    ///
150
    /// - Returns `true` if the set did not previously contain an equal value.
151
    /// - Returns `false` otherwise and the entry is not updated.
152
    #[inline]
153
597k
    pub fn insert(&mut self, value: T) -> bool {
154
597k
        self.inner.insert(value)
155
597k
    }
<wasmparser::collections::set::Set<wasmparser::validator::component_types::ComponentAnyTypeId>>::insert
Line
Count
Source
153
209k
    pub fn insert(&mut self, value: T) -> bool {
154
209k
        self.inner.insert(value)
155
209k
    }
<wasmparser::collections::set::Set<&wasmparser::validator::names::KebabStr>>::insert
Line
Count
Source
153
65.2k
    pub fn insert(&mut self, value: T) -> bool {
154
65.2k
        self.inner.insert(value)
155
65.2k
    }
<wasmparser::collections::set::Set<u32>>::insert
Line
Count
Source
153
322k
    pub fn insert(&mut self, value: T) -> bool {
154
322k
        self.inner.insert(value)
155
322k
    }
156
157
    /// If the set contains an element equal to the value, removes it from the [`Set`] and drops it.
158
    ///
159
    /// Returns `true` if such an element was present, otherwise `false`.
160
    #[inline]
161
0
    pub fn remove<Q>(&mut self, value: &Q) -> bool
162
0
    where
163
0
        T: Borrow<Q>,
164
0
        Q: ?Sized + Hash + Eq + Ord,
165
    {
166
0
        self.inner.remove(value)
167
0
    }
168
169
    /// Removes and returns the element in the [`Set`], if any, that is equal to
170
    /// the value.
171
    ///
172
    /// The value may be any borrowed form of the set's element type,
173
    /// but the ordering on the borrowed form *must* match the
174
    /// ordering on the element type.
175
    #[inline]
176
0
    pub fn take<Q>(&mut self, value: &Q) -> Option<T>
177
0
    where
178
0
        T: Borrow<Q>,
179
0
        Q: ?Sized + Hash + Ord,
180
    {
181
0
        self.inner.take(value)
182
0
    }
183
184
    /// Adds a value to the [`Set`], replacing the existing value, if any, that is equal to the given
185
    /// one. Returns the replaced value.
186
    #[inline]
187
0
    pub fn replace(&mut self, value: T) -> Option<T> {
188
0
        self.inner.replace(value)
189
0
    }
190
191
    /// Returns `true` if `self` has no elements in common with `other`.
192
    /// This is equivalent to checking for an empty intersection.
193
    #[inline]
194
0
    pub fn is_disjoint(&self, other: &Self) -> bool {
195
0
        self.inner.is_disjoint(&other.inner)
196
0
    }
197
198
    /// Returns `true` if the [`Set`] is a subset of another,
199
    /// i.e., `other` contains at least all the values in `self`.
200
    #[inline]
201
0
    pub fn is_subset(&self, other: &Self) -> bool {
202
0
        self.inner.is_subset(&other.inner)
203
0
    }
204
205
    /// Returns `true` if the [`Set`] is a superset of another,
206
    /// i.e., `self` contains at least all the values in `other`.
207
    #[inline]
208
0
    pub fn is_superset(&self, other: &Self) -> bool {
209
0
        self.inner.is_superset(&other.inner)
210
0
    }
211
212
    /// Visits the values representing the difference,
213
    /// i.e., the values that are in `self` but not in `other`.
214
    #[inline]
215
0
    pub fn difference<'a>(&'a self, other: &'a Self) -> Difference<'a, T> {
216
0
        Difference {
217
0
            inner: self.inner.difference(&other.inner),
218
0
        }
219
0
    }
220
221
    /// Visits the values representing the symmetric difference,
222
    /// i.e., the values that are in `self` or in `other` but not in both.
223
    #[inline]
224
0
    pub fn symmetric_difference<'a>(&'a self, other: &'a Self) -> SymmetricDifference<'a, T> {
225
0
        SymmetricDifference {
226
0
            inner: self.inner.symmetric_difference(&other.inner),
227
0
        }
228
0
    }
229
230
    /// Visits the values representing the intersection,
231
    /// i.e., the values that are both in `self` and `other`.
232
    ///
233
    /// When an equal element is present in `self` and `other`
234
    /// then the resulting `Intersection` may yield references to
235
    /// one or the other. This can be relevant if `T` contains fields which
236
    /// are not compared by its `Eq` implementation, and may hold different
237
    /// value between the two equal copies of `T` in the two sets.
238
    #[inline]
239
0
    pub fn intersection<'a>(&'a self, other: &'a Self) -> Intersection<'a, T> {
240
0
        Intersection {
241
0
            inner: self.inner.intersection(&other.inner),
242
0
        }
243
0
    }
244
245
    /// Visits the values representing the union,
246
    /// i.e., all the values in `self` or `other`, without duplicates.
247
    #[inline]
248
0
    pub fn union<'a>(&'a self, other: &'a Self) -> Union<'a, T> {
249
0
        Union {
250
0
            inner: self.inner.union(&other.inner),
251
0
        }
252
0
    }
253
}
254
255
impl<T> PartialEq for Set<T>
256
where
257
    T: Eq + Hash,
258
{
259
    #[inline]
260
0
    fn eq(&self, other: &Self) -> bool {
261
0
        self.inner == other.inner
262
0
    }
263
}
264
265
impl<T> Eq for Set<T> where T: Eq + Hash {}
266
267
impl<T> FromIterator<T> for Set<T>
268
where
269
    T: Hash + Eq + Ord,
270
{
271
    #[inline]
272
0
    fn from_iter<I>(iter: I) -> Self
273
0
    where
274
0
        I: IntoIterator<Item = T>,
275
    {
276
0
        Self {
277
0
            inner: <detail::SetImpl<T>>::from_iter(iter),
278
0
        }
279
0
    }
280
}
281
282
impl<'a, T> IntoIterator for &'a Set<T> {
283
    type Item = &'a T;
284
    type IntoIter = Iter<'a, T>;
285
286
    #[inline]
287
0
    fn into_iter(self) -> Self::IntoIter {
288
0
        self.iter()
289
0
    }
290
}
291
292
impl<'a, T> Extend<&'a T> for Set<T>
293
where
294
    T: Hash + Eq + Ord + Copy + 'a,
295
{
296
    #[inline]
297
0
    fn extend<Iter: IntoIterator<Item = &'a T>>(&mut self, iter: Iter) {
298
0
        self.inner.extend(iter)
299
0
    }
300
}
301
302
impl<T> Extend<T> for Set<T>
303
where
304
    T: Hash + Eq + Ord,
305
{
306
    #[inline]
307
0
    fn extend<Iter: IntoIterator<Item = T>>(&mut self, iter: Iter) {
308
0
        self.inner.extend(iter)
309
0
    }
310
}
311
312
impl<'a, T> BitAnd<Self> for &'a Set<T>
313
where
314
    T: Eq + Hash + Ord + Clone + 'a,
315
{
316
    type Output = Set<T>;
317
318
    #[inline]
319
0
    fn bitand(self, rhs: Self) -> Set<T> {
320
0
        Set {
321
0
            inner: BitAnd::bitand(&self.inner, &rhs.inner),
322
0
        }
323
0
    }
324
}
325
326
impl<'a, T> BitOr<Self> for &'a Set<T>
327
where
328
    T: Eq + Hash + Ord + Clone + 'a,
329
{
330
    type Output = Set<T>;
331
332
    #[inline]
333
0
    fn bitor(self, rhs: Self) -> Set<T> {
334
0
        Set {
335
0
            inner: BitOr::bitor(&self.inner, &rhs.inner),
336
0
        }
337
0
    }
338
}
339
340
impl<'a, T> BitXor<Self> for &'a Set<T>
341
where
342
    T: Eq + Hash + Ord + Clone + 'a,
343
{
344
    type Output = Set<T>;
345
346
    #[inline]
347
0
    fn bitxor(self, rhs: Self) -> Set<T> {
348
0
        Set {
349
0
            inner: BitXor::bitxor(&self.inner, &rhs.inner),
350
0
        }
351
0
    }
352
}
353
354
impl<'a, T> Sub<Self> for &'a Set<T>
355
where
356
    T: Eq + Hash + Ord + Clone + 'a,
357
{
358
    type Output = Set<T>;
359
360
    #[inline]
361
0
    fn sub(self, rhs: Self) -> Set<T> {
362
0
        Set {
363
0
            inner: Sub::sub(&self.inner, &rhs.inner),
364
0
        }
365
0
    }
366
}
367
368
/// An iterator over the items of a [`Set`].
369
#[derive(Debug, Clone)]
370
pub struct Iter<'a, T> {
371
    inner: detail::IterImpl<'a, T>,
372
}
373
374
impl<'a, T: 'a> Iterator for Iter<'a, T> {
375
    type Item = &'a T;
376
377
    #[inline]
378
0
    fn size_hint(&self) -> (usize, Option<usize>) {
379
0
        self.inner.size_hint()
380
0
    }
381
382
    #[inline]
383
0
    fn next(&mut self) -> Option<Self::Item> {
384
0
        self.inner.next()
385
0
    }
386
}
387
388
impl<'a, T: 'a> ExactSizeIterator for Iter<'a, T> {
389
    #[inline]
390
0
    fn len(&self) -> usize {
391
0
        self.inner.len()
392
0
    }
393
}
394
395
impl<'a, T: 'a> FusedIterator for Iter<'a, T> where detail::IterImpl<'a, T>: FusedIterator {}
396
397
impl<T> IntoIterator for Set<T> {
398
    type Item = T;
399
    type IntoIter = IntoIter<T>;
400
401
    #[inline]
402
0
    fn into_iter(self) -> Self::IntoIter {
403
0
        IntoIter {
404
0
            inner: self.inner.into_iter(),
405
0
        }
406
0
    }
407
}
408
409
/// An iterator over the owned items of an [`Set`].
410
#[derive(Debug)]
411
pub struct IntoIter<T> {
412
    inner: detail::IntoIterImpl<T>,
413
}
414
415
impl<T> Iterator for IntoIter<T> {
416
    type Item = T;
417
418
    #[inline]
419
0
    fn size_hint(&self) -> (usize, Option<usize>) {
420
0
        self.inner.size_hint()
421
0
    }
422
423
    #[inline]
424
0
    fn next(&mut self) -> Option<Self::Item> {
425
0
        self.inner.next()
426
0
    }
427
}
428
429
impl<T> ExactSizeIterator for IntoIter<T> {
430
    #[inline]
431
0
    fn len(&self) -> usize {
432
0
        self.inner.len()
433
0
    }
434
}
435
436
impl<T> FusedIterator for IntoIter<T> where detail::IntoIterImpl<T>: FusedIterator {}
437
438
/// A lazy iterator producing elements in the difference of [`Set`]s.
439
///
440
/// This `struct` is created by the [`difference`] method on [`Set`].
441
/// See its documentation for more.
442
///
443
/// [`difference`]: Set::difference
444
pub struct Difference<'a, T: 'a> {
445
    inner: detail::DifferenceImpl<'a, T>,
446
}
447
448
impl<T> Debug for Difference<'_, T>
449
where
450
    T: Debug + Hash + Eq,
451
{
452
0
    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
453
0
        self.inner.fmt(f)
454
0
    }
455
}
456
457
impl<T> Clone for Difference<'_, T> {
458
    #[inline]
459
0
    fn clone(&self) -> Self {
460
0
        Self {
461
0
            inner: self.inner.clone(),
462
0
        }
463
0
    }
464
}
465
466
impl<'a, T> Iterator for Difference<'a, T>
467
where
468
    T: Hash + Eq + Ord,
469
{
470
    type Item = &'a T;
471
472
    #[inline]
473
0
    fn next(&mut self) -> Option<Self::Item> {
474
0
        self.inner.next()
475
0
    }
476
477
    #[inline]
478
0
    fn size_hint(&self) -> (usize, Option<usize>) {
479
0
        self.inner.size_hint()
480
0
    }
481
}
482
483
impl<'a, T> FusedIterator for Difference<'a, T>
484
where
485
    T: Hash + Eq + Ord,
486
    detail::DifferenceImpl<'a, T>: FusedIterator,
487
{
488
}
489
490
/// A lazy iterator producing elements in the intersection of [`Set`]s.
491
///
492
/// This `struct` is created by the [`intersection`] method on [`Set`].
493
/// See its documentation for more.
494
///
495
/// [`intersection`]: Set::intersection
496
pub struct Intersection<'a, T: 'a> {
497
    inner: detail::IntersectionImpl<'a, T>,
498
}
499
500
impl<T> Debug for Intersection<'_, T>
501
where
502
    T: Debug + Hash + Eq,
503
{
504
0
    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
505
0
        self.inner.fmt(f)
506
0
    }
507
}
508
509
impl<T> Clone for Intersection<'_, T> {
510
    #[inline]
511
0
    fn clone(&self) -> Self {
512
0
        Self {
513
0
            inner: self.inner.clone(),
514
0
        }
515
0
    }
516
}
517
518
impl<'a, T> Iterator for Intersection<'a, T>
519
where
520
    T: Hash + Eq + Ord,
521
{
522
    type Item = &'a T;
523
524
    #[inline]
525
0
    fn next(&mut self) -> Option<Self::Item> {
526
0
        self.inner.next()
527
0
    }
528
529
    #[inline]
530
0
    fn size_hint(&self) -> (usize, Option<usize>) {
531
0
        self.inner.size_hint()
532
0
    }
533
}
534
535
impl<'a, T> FusedIterator for Intersection<'a, T>
536
where
537
    T: Hash + Eq + Ord,
538
    detail::IntersectionImpl<'a, T>: FusedIterator,
539
{
540
}
541
542
/// A lazy iterator producing elements in the symmetric difference of [`Set`]s.
543
///
544
/// This `struct` is created by the [`symmetric_difference`] method on
545
/// [`Set`]. See its documentation for more.
546
///
547
/// [`symmetric_difference`]: Set::symmetric_difference
548
pub struct SymmetricDifference<'a, T: 'a> {
549
    inner: detail::SymmetricDifferenceImpl<'a, T>,
550
}
551
552
impl<T> Debug for SymmetricDifference<'_, T>
553
where
554
    T: Debug + Hash + Eq,
555
{
556
0
    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
557
0
        self.inner.fmt(f)
558
0
    }
559
}
560
561
impl<T> Clone for SymmetricDifference<'_, T> {
562
    #[inline]
563
0
    fn clone(&self) -> Self {
564
0
        Self {
565
0
            inner: self.inner.clone(),
566
0
        }
567
0
    }
568
}
569
570
impl<'a, T> Iterator for SymmetricDifference<'a, T>
571
where
572
    T: Hash + Eq + Ord,
573
{
574
    type Item = &'a T;
575
576
    #[inline]
577
0
    fn next(&mut self) -> Option<Self::Item> {
578
0
        self.inner.next()
579
0
    }
580
581
    #[inline]
582
0
    fn size_hint(&self) -> (usize, Option<usize>) {
583
0
        self.inner.size_hint()
584
0
    }
585
}
586
587
impl<'a, T> FusedIterator for SymmetricDifference<'a, T>
588
where
589
    T: Hash + Eq + Ord,
590
    detail::SymmetricDifferenceImpl<'a, T>: FusedIterator,
591
{
592
}
593
594
/// A lazy iterator producing elements in the union of [`Set`]s.
595
///
596
/// This `struct` is created by the [`union`] method on
597
/// [`Set`]. See its documentation for more.
598
///
599
/// [`union`]: Set::union
600
pub struct Union<'a, T: 'a> {
601
    inner: detail::UnionImpl<'a, T>,
602
}
603
604
impl<T> Debug for Union<'_, T>
605
where
606
    T: Debug + Hash + Eq,
607
{
608
0
    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
609
0
        self.inner.fmt(f)
610
0
    }
611
}
612
613
impl<T> Clone for Union<'_, T> {
614
    #[inline]
615
0
    fn clone(&self) -> Self {
616
0
        Self {
617
0
            inner: self.inner.clone(),
618
0
        }
619
0
    }
620
}
621
622
impl<'a, T> Iterator for Union<'a, T>
623
where
624
    T: Hash + Eq + Ord,
625
{
626
    type Item = &'a T;
627
628
    #[inline]
629
0
    fn next(&mut self) -> Option<Self::Item> {
630
0
        self.inner.next()
631
0
    }
632
633
    #[inline]
634
0
    fn size_hint(&self) -> (usize, Option<usize>) {
635
0
        self.inner.size_hint()
636
0
    }
637
}
638
639
impl<'a, T> FusedIterator for Union<'a, T>
640
where
641
    T: Hash + Eq + Ord,
642
    detail::UnionImpl<'a, T>: FusedIterator,
643
{
644
}
645
646
#[cfg(feature = "serde")]
647
impl<T> serde::Serialize for Set<T>
648
where
649
    T: serde::Serialize + Eq + Hash + Ord,
650
{
651
    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
652
    where
653
        S: serde::ser::Serializer,
654
    {
655
        serde::Serialize::serialize(&self.inner, serializer)
656
    }
657
}
658
659
#[cfg(feature = "serde")]
660
impl<'a, T> serde::Deserialize<'a> for Set<T>
661
where
662
    T: serde::Deserialize<'a> + Eq + Hash + Ord,
663
{
664
    fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
665
    where
666
        D: serde::de::Deserializer<'a>,
667
    {
668
        Ok(Set {
669
            inner: serde::Deserialize::deserialize(deserializer)?,
670
        })
671
    }
672
}