1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
use crate::{
	Clear, Collection, CollectionMut, CollectionRef, Get, Insert, Iter, Len, Remove,
	SimpleCollectionMut, SimpleCollectionRef,
};
use alloc::collections::BTreeSet;
use core::borrow::Borrow;

impl<T> Collection for BTreeSet<T> {
	type Item = T;
}

impl<T> CollectionRef for BTreeSet<T> {
	type ItemRef<'a> = &'a T where Self: 'a;

	crate::covariant_item_ref!();
}

impl<T> CollectionMut for BTreeSet<T> {
	type ItemMut<'a> = &'a mut T where Self: 'a;

	crate::covariant_item_mut!();
}

impl<T> SimpleCollectionRef for BTreeSet<T> {
	crate::simple_collection_ref!();
}

impl<T> SimpleCollectionMut for BTreeSet<T> {
	crate::simple_collection_mut!();
}

impl<T> Len for BTreeSet<T> {
	#[inline(always)]
	fn len(&self) -> usize {
		self.len()
	}

	#[inline(always)]
	fn is_empty(&self) -> bool {
		self.is_empty()
	}
}

impl<'a, Q, T: Ord> Get<&'a Q> for BTreeSet<T>
where
	T: Borrow<Q>,
	Q: Ord + ?Sized,
{
	#[inline(always)]
	fn get(&self, t: &'a Q) -> Option<&T> {
		self.get(t)
	}
}

impl<T: Ord> Insert for BTreeSet<T> {
	type Output = bool;

	#[inline(always)]
	fn insert(&mut self, t: T) -> bool {
		self.insert(t)
	}
}

impl<'a, Q, T: Ord> Remove<&'a Q> for BTreeSet<T>
where
	T: Borrow<Q>,
	Q: Ord + ?Sized,
{
	#[inline(always)]
	fn remove(&mut self, t: &'a Q) -> Option<T> {
		self.take(t)
	}
}

impl<T: Ord> Clear for BTreeSet<T> {
	#[inline(always)]
	fn clear(&mut self) {
		self.clear()
	}
}

impl<T> Iter for BTreeSet<T> {
	type Iter<'a> = alloc::collections::btree_set::Iter<'a, T> where Self: 'a;

	#[inline(always)]
	fn iter(&self) -> Self::Iter<'_> {
		self.iter()
	}
}