Debian Codegraph @

src/set.rs

raw symbols ◀ ▶ SCIP
1 Debian patch touch this file
1 use corerust-analyzer cargo core https://github.com/rust-lang/rust/library/core crate/::borrowrust-analyzer cargo core https://github.com/rust-lang/rust/library/core borrow/::Borrowrust-analyzer cargo core https://github.com/rust-lang/rust/library/core borrow/Borrow#;
2 use corerust-analyzer cargo core https://github.com/rust-lang/rust/library/core crate/::fmtrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/::{selfrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/, Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Debug#};
3 use corerust-analyzer cargo core https://github.com/rust-lang/rust/library/core crate/::iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/::FromIteratorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/collect/FromIterator#;
4 use corerust-analyzer cargo core https://github.com/rust-lang/rust/library/core crate/::opsrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/::{BitAndrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/BitAnd#, BitOrrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/BitOr#, Rangerust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#};
5 use corerust-analyzer cargo core https://github.com/rust-lang/rust/library/core crate/::preluderust-analyzer cargo core https://github.com/rust-lang/rust/library/core prelude/::v1rust-analyzer cargo core https://github.com/rust-lang/rust/library/core prelude/v1/::*;
6
7 #[cfg(feature = "serde1")]
8 use corerust-analyzer cargo core https://github.com/rust-lang/rust/library/core crate/::markerrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/::PhantomDatarust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/PhantomData#;
9 #[cfg(feature = "serde1")]
10 use serderust-analyzer cargo serde 1.0.219 crate/::{
11 derust-analyzer cargo serde 1.0.219 de/::{Deserializerust-analyzer cargo serde 1.0.219 de/Deserialize#, Deserializerrust-analyzer cargo serde 1.0.219 de/Deserializer#, SeqAccessrust-analyzer cargo serde 1.0.219 de/SeqAccess#, Visitorrust-analyzer cargo serde 1.0.219 de/Visitor#},
12 serrust-analyzer cargo serde 1.0.219 ser/::{Serializerust-analyzer cargo serde 1.0.219 ser/Serialize#, Serializerrust-analyzer cargo serde 1.0.219 ser/Serializer#},
13 };
14
15 use craterust-analyzer cargo rangemap 1.7.1 crate/::RangeMaprust-analyzer cargo rangemap 1.7.1 map/RangeMap#;
16
17 /// Intersection iterator over two [`RangeSet`].
18 pub type Intersectionrust-analyzer cargo rangemap 1.7.1 set/Intersection#<'a, T> = craterust-analyzer cargo rangemap 1.7.1 crate/::operationsrust-analyzer cargo rangemap 1.7.1 operations/::Intersectionrust-analyzer cargo rangemap 1.7.1 operations/Intersection#<'a, Rangerust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#<T>, Iterrust-analyzer cargo rangemap 1.7.1 set/Iter#<'a, T>>;
19
20 /// Union iterator over two [`RangeSet`].
21 pub type Unionrust-analyzer cargo rangemap 1.7.1 set/Union#<'a, T> = craterust-analyzer cargo rangemap 1.7.1 crate/::operationsrust-analyzer cargo rangemap 1.7.1 operations/::Unionrust-analyzer cargo rangemap 1.7.1 operations/Union#<'a, Rangerust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#<T>, Iterrust-analyzer cargo rangemap 1.7.1 set/Iter#<'a, T>>;
22
23 #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone:, Hashrust-analyzer cargo core https://github.com/rust-lang/rust/library/core hash/macros/Hash:, Eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Eq:, PartialEqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq:, PartialOrdrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialOrd:, Ordrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Ord:)]
24 /// A set whose items are stored as (half-open) ranges bounded
25 /// inclusively below and exclusively above `(start..end)`.
26 ///
27 /// See [`RangeMap`]'s documentation for more details.
28 ///
29 /// [`RangeMap`]: crate::RangeMap
30 pub struct RangeSetrust-analyzer cargo rangemap 1.7.1 set/RangeSet#<T> {
31 rmrust-analyzer cargo rangemap 1.7.1 set/RangeSet#rm.: RangeMaprust-analyzer cargo rangemap 1.7.1 map/RangeMap#<T, ()>,
32 }
33
34 impl<T> Defaultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core default/Default# for RangeSetrust-analyzer cargo rangemap 1.7.1 set/RangeSet#<T> {
35 fn defaultrust-analyzer cargo rangemap 1.7.1 set/impl#[`RangeSet<T>`][Default]default().() -> Selfrust-analyzer cargo rangemap 1.7.1 set/impl#[`RangeSet<T>`][Default] {
36 Selfrust-analyzer cargo rangemap 1.7.1 set/impl#[`RangeSet<T>`][Default] {
37 rmrust-analyzer cargo rangemap 1.7.1 set/RangeSet#rm.: RangeMaprust-analyzer cargo rangemap 1.7.1 map/RangeMap#::defaultrust-analyzer cargo rangemap 1.7.1 map/impl#[`RangeMap<K, V>`][Default]default().(),
38 }
39 }
40 }
41
42 #[cfg(feature = "quickcheck")]
43 impl<K> quickcheckrust-analyzer cargo quickcheck 1.0.3 crate/::Arbitraryrust-analyzer cargo quickcheck 1.0.3 arbitrary/Arbitrary# for RangeSetrust-analyzer cargo rangemap 1.7.1 set/RangeSet#<K>
44 where
45 K: quickcheckrust-analyzer cargo quickcheck 1.0.3 crate/::Arbitraryrust-analyzer cargo quickcheck 1.0.3 arbitrary/Arbitrary# + Ordrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Ord#,
46 {
47 fn arbitraryrust-analyzer cargo rangemap 1.7.1 set/impl#[`RangeSet<K>`][Arbitrary]arbitrary().(g: &mut quickcheckrust-analyzer cargo quickcheck 1.0.3 crate/::Genrust-analyzer cargo quickcheck 1.0.3 arbitrary/Gen#) -> Selfrust-analyzer cargo rangemap 1.7.1 set/impl#[`RangeSet<K>`][Arbitrary] {
48 Selfrust-analyzer cargo rangemap 1.7.1 set/impl#[`RangeSet<K>`][Arbitrary] {
49 rmrust-analyzer cargo rangemap 1.7.1 set/RangeSet#rm.: RangeMaprust-analyzer cargo rangemap 1.7.1 map/RangeMap#::arbitraryrust-analyzer cargo rangemap 1.7.1 map/impl#[`RangeMap<K, V>`][Arbitrary]arbitrary().(g),
50 }
51 }
52 }
53
54 impl<T> RangeSetrust-analyzer cargo rangemap 1.7.1 set/RangeSet#<T>
55 where
56 T: Ordrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Ord# + Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone#,
57 {
58 /// Makes a new empty `RangeSet`.
59 #[cfg(feature = "const_fn")]
60 pub const fn newrust-analyzer cargo rangemap 1.7.1 set/impl#[`RangeSet<T>`]new().() -> Selfrust-analyzer cargo rangemap 1.7.1 set/impl#[`RangeSet<T>`] {
61 RangeSetrust-analyzer cargo rangemap 1.7.1 set/RangeSet# {
62 rmrust-analyzer cargo rangemap 1.7.1 set/RangeSet#rm.: RangeMaprust-analyzer cargo rangemap 1.7.1 map/RangeMap#::newrust-analyzer cargo rangemap 1.7.1 map/impl#[`RangeMap<K, V>`]new().(),
63 }
64 }
65
66 /// Makes a new empty `RangeSet`.
67 #[cfg(not(feature = "const_fn"))]
68 pub fn new() -> Selfrust-analyzer cargo rangemap 1.7.1 set/impl#[`RangeSet<T>`] {
69 RangeSetrust-analyzer cargo rangemap 1.7.1 set/RangeSet# {
70 rm: RangeMaprust-analyzer cargo rangemap 1.7.1 map/RangeMap#::new(),
71 }
72 }
73
74 /// Returns a reference to the range covering the given key, if any.
75 pub fn getrust-analyzer cargo rangemap 1.7.1 set/impl#[`RangeSet<T>`]get().(&self, value: &T) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<&Rangerust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#<T>> {
76 self.rmrust-analyzer cargo rangemap 1.7.1 set/RangeSet#rm..get_key_valuerust-analyzer cargo rangemap 1.7.1 map/impl#[`RangeMap<K, V>`]get_key_value().(value).maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]map().(|(range, _)| range)
77 }
78
79 /// Returns `true` if any range in the set covers the specified value.
80 pub fn containsrust-analyzer cargo rangemap 1.7.1 set/impl#[`RangeSet<T>`]contains().(&self, value: &T) -> bool {
81 self.rmrust-analyzer cargo rangemap 1.7.1 set/RangeSet#rm..contains_keyrust-analyzer cargo rangemap 1.7.1 map/impl#[`RangeMap<K, V>`]contains_key().(value)
82 }
83
84 /// Gets an ordered iterator over all ranges,
85 /// ordered by range.
86 pub fn iterrust-analyzer cargo rangemap 1.7.1 set/impl#[`RangeSet<T>`]iter().(&self) -> Iterrust-analyzer cargo rangemap 1.7.1 set/Iter#<'_, T> {
87 Iterrust-analyzer cargo rangemap 1.7.1 set/Iter# {
88 innerrust-analyzer cargo rangemap 1.7.1 set/Iter#inner.: self.rmrust-analyzer cargo rangemap 1.7.1 set/RangeSet#rm..iterrust-analyzer cargo rangemap 1.7.1 map/impl#[`RangeMap<K, V>`]iter().(),
89 }
90 }
91
92 /// Clears the set, removing all elements.
93 pub fn clearrust-analyzer cargo rangemap 1.7.1 set/impl#[`RangeSet<T>`]clear().(&mut self) {
94 self.rmrust-analyzer cargo rangemap 1.7.1 set/RangeSet#rm..clearrust-analyzer cargo rangemap 1.7.1 map/impl#[`RangeMap<K, V>`]clear().();
95 }
96
97 /// Returns the number of elements in the set.
98 pub fn lenrust-analyzer cargo rangemap 1.7.1 set/impl#[`RangeSet<T>`]len().(&self) -> usize {
99 self.rmrust-analyzer cargo rangemap 1.7.1 set/RangeSet#rm..lenrust-analyzer cargo rangemap 1.7.1 map/impl#[`RangeMap<K, V>`]len().()
100 }
101
102 /// Returns true if the set contains no elements.
103 pub fn is_emptyrust-analyzer cargo rangemap 1.7.1 set/impl#[`RangeSet<T>`]is_empty().(&self) -> bool {
104 self.rmrust-analyzer cargo rangemap 1.7.1 set/RangeSet#rm..is_emptyrust-analyzer cargo rangemap 1.7.1 map/impl#[`RangeMap<K, V>`]is_empty().()
105 }
106
107 /// Return an iterator over the intersection of two range sets.
108 pub fn intersectionrust-analyzer cargo rangemap 1.7.1 set/impl#[`RangeSet<T>`]intersection().<'a>(&'a self, other: &'a Selfrust-analyzer cargo rangemap 1.7.1 set/impl#[`RangeSet<T>`]) -> Intersectionrust-analyzer cargo rangemap 1.7.1 set/Intersection#<'a, T> {
109 Intersectionrust-analyzer cargo rangemap 1.7.1 set/Intersection#::newrust-analyzer cargo rangemap 1.7.1 operations/impl#[`Intersection<'a, T, L, R>`]new().(self.iterrust-analyzer cargo rangemap 1.7.1 set/impl#[`RangeSet<T>`]iter().(), other.iterrust-analyzer cargo rangemap 1.7.1 set/impl#[`RangeSet<T>`]iter().())
110 }
111
112 /// Return an iterator over the union of two range sets.
113 pub fn unionrust-analyzer cargo rangemap 1.7.1 set/impl#[`RangeSet<T>`]union().<'a>(&'a self, other: &'a Selfrust-analyzer cargo rangemap 1.7.1 set/impl#[`RangeSet<T>`]) -> Unionrust-analyzer cargo rangemap 1.7.1 set/Union#<'a, T> {
114 Unionrust-analyzer cargo rangemap 1.7.1 set/Union#::newrust-analyzer cargo rangemap 1.7.1 operations/impl#[`Union<'a, T, L, R>`]new().(self.iterrust-analyzer cargo rangemap 1.7.1 set/impl#[`RangeSet<T>`]iter().(), other.iterrust-analyzer cargo rangemap 1.7.1 set/impl#[`RangeSet<T>`]iter().())
115 }
116
117 /// Insert a range into the set.
118 ///
119 /// If the inserted range either overlaps or is immediately adjacent
120 /// any existing range, then the ranges will be coalesced into
121 /// a single contiguous range.
122 ///
123 /// # Panics
124 ///
125 /// Panics if range `start >= end`.
126 pub fn insertrust-analyzer cargo rangemap 1.7.1 set/impl#[`RangeSet<T>`]insert().(&mut self, range: Rangerust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#<T>) {
127 self.rmrust-analyzer cargo rangemap 1.7.1 set/RangeSet#rm..insertrust-analyzer cargo rangemap 1.7.1 map/impl#[`RangeMap<K, V>`]insert().(range, ());
128 }
129
130 /// Removes a range from the set, if all or any of it was present.
131 ///
132 /// If the range to be removed _partially_ overlaps any ranges
133 /// in the set, then those ranges will be contracted to no
134 /// longer cover the removed range.
135 ///
136 /// # Panics
137 ///
138 /// Panics if range `start >= end`.
139 pub fn removerust-analyzer cargo rangemap 1.7.1 set/impl#[`RangeSet<T>`]remove().(&mut self, range: Rangerust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#<T>) {
140 self.rmrust-analyzer cargo rangemap 1.7.1 set/RangeSet#rm..removerust-analyzer cargo rangemap 1.7.1 map/impl#[`RangeMap<K, V>`]remove().(range);
141 }
142
143 /// Gets an iterator over all the maximally-sized ranges
144 /// contained in `outer_range` that are not covered by
145 /// any range stored in the set.
146 ///
147 /// If the start and end of the outer range are the same
148 /// and it does not overlap any stored range, then a single
149 /// empty gap will be returned.
150 ///
151 /// The iterator element type is `Range<T>`.
152 pub fn gapsrust-analyzer cargo rangemap 1.7.1 set/impl#[`RangeSet<T>`]gaps().<'a>(&'a self, outer_range: &'a Rangerust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#<T>) -> Gapsrust-analyzer cargo rangemap 1.7.1 set/Gaps#<'a, T> {
153 Gapsrust-analyzer cargo rangemap 1.7.1 set/Gaps# {
154 innerrust-analyzer cargo rangemap 1.7.1 set/Gaps#inner.: self.rmrust-analyzer cargo rangemap 1.7.1 set/RangeSet#rm..gapsrust-analyzer cargo rangemap 1.7.1 map/impl#[`RangeMap<K, V>`]gaps().(outer_range),
155 }
156 }
157
158 /// Gets an iterator over all the stored ranges that are
159 /// either partially or completely overlapped by the given range.
160 ///
161 /// The iterator element type is `&Range<T>`.
162 pub fn overlappingrust-analyzer cargo rangemap 1.7.1 set/impl#[`RangeSet<T>`]overlapping().<R: Borrowrust-analyzer cargo core https://github.com/rust-lang/rust/library/core borrow/Borrow#<Rangerust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#<T>>>(&'_ self, range: R) -> Overlappingrust-analyzer cargo rangemap 1.7.1 set/Overlapping#<'_, T, R> {
163 Overlappingrust-analyzer cargo rangemap 1.7.1 set/Overlapping# {
164 innerrust-analyzer cargo rangemap 1.7.1 set/Overlapping#inner.: self.rmrust-analyzer cargo rangemap 1.7.1 set/RangeSet#rm..overlappingrust-analyzer cargo rangemap 1.7.1 map/impl#[`RangeMap<K, V>`]overlapping().(range),
165 }
166 }
167
168 /// Returns `true` if any range in the set completely or partially
169 /// overlaps the given range.
170 pub fn overlapsrust-analyzer cargo rangemap 1.7.1 set/impl#[`RangeSet<T>`]overlaps().(&self, range: &Rangerust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#<T>) -> bool {
171 self.overlappingrust-analyzer cargo rangemap 1.7.1 set/impl#[`RangeSet<T>`]overlapping().(range).nextrust-analyzer cargo rangemap 1.7.1 set/impl#[`Overlapping<'a, T, R>`][Iterator]next().().is_somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]is_some().()
172 }
173
174 /// Returns the first range in the set, if one exists. The range is the minimum range in this
175 /// set.
176 pub fn firstrust-analyzer cargo rangemap 1.7.1 set/impl#[`RangeSet<T>`]first().(&self) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<&Rangerust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#<T>> {
177 self.rmrust-analyzer cargo rangemap 1.7.1 set/RangeSet#rm..first_range_valuerust-analyzer cargo rangemap 1.7.1 map/impl#[`RangeMap<K, V>`]first_range_value().().maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]map().(|(range, _)| range)
178 }
179
180 /// Returns the last range in the set, if one exists. The range is the maximum range in this
181 /// set.
182 pub fn lastrust-analyzer cargo rangemap 1.7.1 set/impl#[`RangeSet<T>`]last().(&self) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<&Rangerust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#<T>> {
183 self.rmrust-analyzer cargo rangemap 1.7.1 set/RangeSet#rm..last_range_valuerust-analyzer cargo rangemap 1.7.1 map/impl#[`RangeMap<K, V>`]last_range_value().().maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]map().(|(range, _)| range)
184 }
185 }
186
187 /// An iterator over the ranges of a `RangeSet`.
188 ///
189 /// This `struct` is created by the [`iter`] method on [`RangeSet`]. See its
190 /// documentation for more.
191 ///
192 /// [`iter`]: RangeSet::iter
193 pub struct Iterrust-analyzer cargo rangemap 1.7.1 set/Iter#<'a, T> {
194 innerrust-analyzer cargo rangemap 1.7.1 set/Iter#inner.: superrust-analyzer cargo rangemap 1.7.1 crate/::maprust-analyzer cargo rangemap 1.7.1 map/::Iterrust-analyzer cargo rangemap 1.7.1 map/Iter#<'a, T, ()>,
195 }
196
197 impl<'a, T> Iteratorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator# for Iterrust-analyzer cargo rangemap 1.7.1 set/Iter#<'a, T> {
198 type Itemrust-analyzer cargo rangemap 1.7.1 set/impl#[`Iter<'a, T>`][Iterator]Item# = &'a Rangerust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#<T>;
199
200 fn nextrust-analyzer cargo rangemap 1.7.1 set/impl#[`Iter<'a, T>`][Iterator]next().(&mut self) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<Selfrust-analyzer cargo rangemap 1.7.1 set/impl#[`Iter<'a, T>`][Iterator]::Itemrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#Item#> {
201 self.innerrust-analyzer cargo rangemap 1.7.1 set/Iter#inner..nextrust-analyzer cargo rangemap 1.7.1 map/impl#[`Iter<'a, K, V>`][Iterator]next().().maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]map().(|(range, _)| range)
202 }
203
204 fn size_hintrust-analyzer cargo rangemap 1.7.1 set/impl#[`Iter<'a, T>`][Iterator]size_hint().(&self) -> (usize, Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<usize>) {
205 self.innerrust-analyzer cargo rangemap 1.7.1 set/Iter#inner..size_hintrust-analyzer cargo rangemap 1.7.1 map/impl#[`Iter<'a, K, V>`][Iterator]size_hint().()
206 }
207 }
208
209 impl<'a, K> DoubleEndedIteratorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/double_ended/DoubleEndedIterator# for Iterrust-analyzer cargo rangemap 1.7.1 set/Iter#<'a, K>
210 where
211 K: 'a,
212 {
213 fn next_backrust-analyzer cargo rangemap 1.7.1 set/impl#[`Iter<'a, K>`][DoubleEndedIterator]next_back().(&mut self) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<Selfrust-analyzer cargo rangemap 1.7.1 set/impl#[`Iter<'a, K>`][DoubleEndedIterator]::Itemrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#Item#> {
214 self.innerrust-analyzer cargo rangemap 1.7.1 set/Iter#inner..next_backrust-analyzer cargo rangemap 1.7.1 map/impl#[`Iter<'a, K, V>`][DoubleEndedIterator]next_back().().maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]map().(|(range, _)| range)
215 }
216 }
217
218 /// An owning iterator over the ranges of a `RangeSet`.
219 ///
220 /// This `struct` is created by the [`into_iter`] method on [`RangeSet`]
221 /// (provided by the `IntoIterator` trait). See its documentation for more.
222 ///
223 /// [`into_iter`]: IntoIterator::into_iter
224 pub struct IntoIterrust-analyzer cargo rangemap 1.7.1 set/IntoIter#<T> {
225 innerrust-analyzer cargo rangemap 1.7.1 set/IntoIter#inner.: superrust-analyzer cargo rangemap 1.7.1 crate/::maprust-analyzer cargo rangemap 1.7.1 map/::IntoIterrust-analyzer cargo rangemap 1.7.1 map/IntoIter#<T, ()>,
226 }
227
228 impl<T> IntoIteratorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/collect/IntoIterator# for RangeSetrust-analyzer cargo rangemap 1.7.1 set/RangeSet#<T> {
229 type Itemrust-analyzer cargo rangemap 1.7.1 set/impl#[`RangeSet<T>`][IntoIterator]Item# = Rangerust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#<T>;
230 type IntoIterrust-analyzer cargo rangemap 1.7.1 set/impl#[`RangeSet<T>`][IntoIterator]IntoIter# = IntoIterrust-analyzer cargo rangemap 1.7.1 set/IntoIter#<T>;
231 fn into_iterrust-analyzer cargo rangemap 1.7.1 set/impl#[`RangeSet<T>`][IntoIterator]into_iter().(self) -> Selfrust-analyzer cargo rangemap 1.7.1 set/impl#[`RangeSet<T>`][IntoIterator]::IntoIterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/collect/IntoIterator#IntoIter# {
232 IntoIterrust-analyzer cargo rangemap 1.7.1 set/IntoIter# {
233 innerrust-analyzer cargo rangemap 1.7.1 set/IntoIter#inner.: self.rmrust-analyzer cargo rangemap 1.7.1 set/RangeSet#rm..into_iterrust-analyzer cargo rangemap 1.7.1 map/impl#[`RangeMap<K, V>`][IntoIterator]into_iter().(),
234 }
235 }
236 }
237
238 impl<T> Iteratorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator# for IntoIterrust-analyzer cargo rangemap 1.7.1 set/IntoIter#<T> {
239 type Itemrust-analyzer cargo rangemap 1.7.1 set/impl#[`IntoIter<T>`][Iterator]Item# = Rangerust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#<T>;
240 fn nextrust-analyzer cargo rangemap 1.7.1 set/impl#[`IntoIter<T>`][Iterator]next().(&mut self) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<Rangerust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#<T>> {
241 self.innerrust-analyzer cargo rangemap 1.7.1 set/IntoIter#inner..nextrust-analyzer cargo rangemap 1.7.1 map/impl#[`IntoIter<K, V>`][Iterator]next().().maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]map().(|(range, _)| range)
242 }
243 fn size_hintrust-analyzer cargo rangemap 1.7.1 set/impl#[`IntoIter<T>`][Iterator]size_hint().(&self) -> (usize, Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<usize>) {
244 self.innerrust-analyzer cargo rangemap 1.7.1 set/IntoIter#inner..size_hintrust-analyzer cargo rangemap 1.7.1 map/impl#[`IntoIter<K, V>`][Iterator]size_hint().()
245 }
246 }
247
248 impl<K> DoubleEndedIteratorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/double_ended/DoubleEndedIterator# for IntoIterrust-analyzer cargo rangemap 1.7.1 set/IntoIter#<K> {
249 fn next_backrust-analyzer cargo rangemap 1.7.1 set/impl#[`IntoIter<K>`][DoubleEndedIterator]next_back().(&mut self) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<Selfrust-analyzer cargo rangemap 1.7.1 set/impl#[`IntoIter<K>`][DoubleEndedIterator]::Itemrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#Item#> {
250 self.innerrust-analyzer cargo rangemap 1.7.1 set/IntoIter#inner..next_backrust-analyzer cargo rangemap 1.7.1 map/impl#[`IntoIter<K, V>`][DoubleEndedIterator]next_back().().maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]map().(|(range, _)| range)
251 }
252 }
253
254 // We can't just derive this automatically, because that would
255 // expose irrelevant (and private) implementation details.
256 // Instead implement it in the same way that the underlying BTreeSet does.
257 impl<T: Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Debug#> Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Debug# for RangeSetrust-analyzer cargo rangemap 1.7.1 set/RangeSet#<T>
258 where
259 T: Ordrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Ord# + Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone#,
260 {
261 fn fmtrust-analyzer cargo rangemap 1.7.1 set/impl#[`RangeSet<T>`][Debug]fmt().(&self, f: &mut fmtrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/::Formatterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Formatter#<'_>) -> fmtrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/::Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Result# {
262 f.debug_setrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/impl#[`Formatter<'a>`]debug_set().().entriesrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/builders/impl#[`DebugSet<'a, 'b>`]entries().(self.iterrust-analyzer cargo rangemap 1.7.1 set/impl#[`RangeSet<T>`]iter().()).finishrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/builders/impl#[`DebugSet<'a, 'b>`]finish().()
263 }
264 }
265
266 impl<T> FromIteratorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/collect/FromIterator#<Rangerust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#<T>> for RangeSetrust-analyzer cargo rangemap 1.7.1 set/RangeSet#<T>
267 where
268 T: Ordrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Ord# + Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone#,
269 {
270 fn from_iterrust-analyzer cargo rangemap 1.7.1 set/impl#[`RangeSet<T>`][`FromIterator<Range<T>>`]from_iter().<I: IntoIteratorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/collect/IntoIterator#<Itemrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/collect/IntoIterator#Item# = Rangerust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#<T>>>(iter: I) -> Selfrust-analyzer cargo rangemap 1.7.1 set/impl#[`RangeSet<T>`][`FromIterator<Range<T>>`] {
271 let mut range_set = RangeSetrust-analyzer cargo rangemap 1.7.1 set/RangeSet#::newrust-analyzer cargo rangemap 1.7.1 set/impl#[`RangeSet<T>`]new().();
272 range_set.extendrust-analyzer cargo rangemap 1.7.1 set/impl#[`RangeSet<T>`][`Extend<Range<T>>`]extend().(iter);
273 range_set
274 }
275 }
276
277 impl<T> Extendrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/collect/Extend#<Rangerust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#<T>> for RangeSetrust-analyzer cargo rangemap 1.7.1 set/RangeSet#<T>
278 where
279 T: Ordrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Ord# + Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone#,
280 {
281 fn extendrust-analyzer cargo rangemap 1.7.1 set/impl#[`RangeSet<T>`][`Extend<Range<T>>`]extend().<I: IntoIteratorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/collect/IntoIterator#<Itemrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/collect/IntoIterator#Item# = Rangerust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#<T>>>(&mut self, iter: I) {
282 iter.into_iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/collect/IntoIterator#into_iter().().for_eachrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#for_each().(move |range| {
283 self.insertrust-analyzer cargo rangemap 1.7.1 set/impl#[`RangeSet<T>`]insert().(range);
284 })
285 }
286 }
287
288 #[cfg(feature = "serde1")]
289 impl<T> Serializerust-analyzer cargo serde 1.0.219 ser/Serialize# for RangeSetrust-analyzer cargo rangemap 1.7.1 set/RangeSet#<T>
290 where
291 T: Ordrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Ord# + Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone# + Serializerust-analyzer cargo serde 1.0.219 ser/Serialize#,
292 {
293 fn serializerust-analyzer cargo rangemap 1.7.1 set/impl#[`RangeSet<T>`][Serialize]serialize().<S>(&self, serializer: S) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<S::Okrust-analyzer cargo serde 1.0.219 ser/Serializer#Ok#, S::Errorrust-analyzer cargo serde 1.0.219 ser/Serializer#Error#>
294 where
295 S: Serializerrust-analyzer cargo serde 1.0.219 ser/Serializer#,
296 {
297 use serderust-analyzer cargo serde 1.0.219 crate/::serrust-analyzer cargo serde 1.0.219 ser/::SerializeSeqrust-analyzer cargo serde 1.0.219 ser/SerializeSeq#;
298 let mut seq = serializer.serialize_seqrust-analyzer cargo serde 1.0.219 ser/Serializer#serialize_seq().(Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(self.rmrust-analyzer cargo rangemap 1.7.1 set/RangeSet#rm..btmrust-analyzer cargo rangemap 1.7.1 map/RangeMap#btm..lenrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/btree/map/impl#[`BTreeMap<K, V, A>`]len().()))?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
299 for range in self.iterrust-analyzer cargo rangemap 1.7.1 set/impl#[`RangeSet<T>`]iter().() {
300 seq.serialize_elementrust-analyzer cargo serde 1.0.219 ser/SerializeSeq#serialize_element().(&(&range.startrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#start., &range.endrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#end.))?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
301 }
302 seq.endrust-analyzer cargo serde 1.0.219 ser/SerializeSeq#end().()
303 }
304 }
305
306 #[cfg(feature = "serde1")]
307 impl<'de, T> Deserializerust-analyzer cargo serde 1.0.219 de/Deserialize#<'de> for RangeSetrust-analyzer cargo rangemap 1.7.1 set/RangeSet#<T>
308 where
309 T: Ordrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Ord# + Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone# + Deserializerust-analyzer cargo serde 1.0.219 de/Deserialize#<'de>,
310 {
311 fn deserializerust-analyzer cargo rangemap 1.7.1 set/impl#[`RangeSet<T>`][`Deserialize<'de>`]deserialize().<D>(deserializer: D) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<Selfrust-analyzer cargo rangemap 1.7.1 set/impl#[`RangeSet<T>`][`Deserialize<'de>`], D::Errorrust-analyzer cargo serde 1.0.219 de/Deserializer#Error#>
312 where
313 D: Deserializerrust-analyzer cargo serde 1.0.219 de/Deserializer#<'de>,
314 {
315 deserializer.deserialize_seqrust-analyzer cargo serde 1.0.219 de/Deserializer#deserialize_seq().(RangeSetVisitorrust-analyzer cargo rangemap 1.7.1 set/RangeSetVisitor#::newrust-analyzer cargo rangemap 1.7.1 set/impl#[`RangeSetVisitor<T>`]new().())
316 }
317 }
318
319 #[cfg(feature = "serde1")]
320 struct RangeSetVisitorrust-analyzer cargo rangemap 1.7.1 set/RangeSetVisitor#<T> {
321 markerrust-analyzer cargo rangemap 1.7.1 set/RangeSetVisitor#marker.: PhantomDatarust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/PhantomData#<fn() -> RangeSetrust-analyzer cargo rangemap 1.7.1 set/RangeSet#<T>>,
322 }
323
324 #[cfg(feature = "serde1")]
325 impl<T> RangeSetVisitorrust-analyzer cargo rangemap 1.7.1 set/RangeSetVisitor#<T> {
326 fn newrust-analyzer cargo rangemap 1.7.1 set/impl#[`RangeSetVisitor<T>`]new().() -> Selfrust-analyzer cargo rangemap 1.7.1 set/impl#[`RangeSetVisitor<T>`] {
327 RangeSetVisitorrust-analyzer cargo rangemap 1.7.1 set/RangeSetVisitor# {
328 markerrust-analyzer cargo rangemap 1.7.1 set/RangeSetVisitor#marker.: PhantomDatarust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/PhantomData#,
329 }
330 }
331 }
332
333 #[cfg(feature = "serde1")]
334 impl<'de, T> Visitorrust-analyzer cargo serde 1.0.219 de/Visitor#<'de> for RangeSetVisitorrust-analyzer cargo rangemap 1.7.1 set/RangeSetVisitor#<T>
335 where
336 T: Ordrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Ord# + Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone# + Deserializerust-analyzer cargo serde 1.0.219 de/Deserialize#<'de>,
337 {
338 type Valuerust-analyzer cargo rangemap 1.7.1 set/impl#[`RangeSetVisitor<T>`][`Visitor<'de>`]Value# = RangeSetrust-analyzer cargo rangemap 1.7.1 set/RangeSet#<T>;
339
340 fn expectingrust-analyzer cargo rangemap 1.7.1 set/impl#[`RangeSetVisitor<T>`][`Visitor<'de>`]expecting().(&self, formatter: &mut fmtrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/::Formatterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Formatter#) -> fmtrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/::Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Result# {
341 formatter.write_strrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/impl#[`Formatter<'a>`]write_str().("RangeSet")
342 }
343
344 fn visit_seqrust-analyzer cargo rangemap 1.7.1 set/impl#[`RangeSetVisitor<T>`][`Visitor<'de>`]visit_seq().<A>(self, mut access: A) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<Selfrust-analyzer cargo rangemap 1.7.1 set/impl#[`RangeSetVisitor<T>`][`Visitor<'de>`]::Valuerust-analyzer cargo serde 1.0.219 de/Visitor#Value#, A::Errorrust-analyzer cargo serde 1.0.219 de/SeqAccess#Error#>
345 where
346 A: SeqAccessrust-analyzer cargo serde 1.0.219 de/SeqAccess#<'de>,
347 {
348 let mut range_set = RangeSetrust-analyzer cargo rangemap 1.7.1 set/RangeSet#::newrust-analyzer cargo rangemap 1.7.1 set/impl#[`RangeSet<T>`]new().();
349 while let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#((start, end)) = access.next_elementrust-analyzer cargo serde 1.0.219 de/SeqAccess#next_element().()?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch(). {
350 range_set.insertrust-analyzer cargo rangemap 1.7.1 set/impl#[`RangeSet<T>`]insert().(start..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#end);
351 }
352 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(range_set)
353 }
354 }
355
356 /// An iterator over all ranges not covered by a `RangeSet`.
357 ///
358 /// This `struct` is created by the [`gaps`] method on [`RangeSet`]. See its
359 /// documentation for more.
360 ///
361 /// [`gaps`]: RangeSet::gaps
362 pub struct Gapsrust-analyzer cargo rangemap 1.7.1 set/Gaps#<'a, T> {
363 innerrust-analyzer cargo rangemap 1.7.1 set/Gaps#inner.: craterust-analyzer cargo rangemap 1.7.1 crate/::maprust-analyzer cargo rangemap 1.7.1 map/::Gapsrust-analyzer cargo rangemap 1.7.1 map/Gaps#<'a, T, ()>,
364 }
365
366 // `Gaps` is always fused. (See definition of `next` below.)
367 impl<'a, T> corerust-analyzer cargo core https://github.com/rust-lang/rust/library/core crate/::iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/::FusedIteratorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/marker/FusedIterator# for Gapsrust-analyzer cargo rangemap 1.7.1 set/Gaps#<'a, T> where T: Ordrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Ord# + Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone# {}
368
369 impl<'a, T> Iteratorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator# for Gapsrust-analyzer cargo rangemap 1.7.1 set/Gaps#<'a, T>
370 where
371 T: Ordrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Ord# + Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone#,
372 {
373 type Itemrust-analyzer cargo rangemap 1.7.1 set/impl#[`Gaps<'a, T>`][Iterator]Item# = Rangerust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#<T>;
374
375 fn nextrust-analyzer cargo rangemap 1.7.1 set/impl#[`Gaps<'a, T>`][Iterator]next().(&mut self) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<Selfrust-analyzer cargo rangemap 1.7.1 set/impl#[`Gaps<'a, T>`][Iterator]::Itemrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#Item#> {
376 self.innerrust-analyzer cargo rangemap 1.7.1 set/Gaps#inner..nextrust-analyzer cargo rangemap 1.7.1 map/impl#[`Gaps<'a, K, V>`][Iterator]next().()
377 }
378 }
379
380 /// An iterator over all stored ranges partially or completely
381 /// overlapped by a given range.
382 ///
383 /// This `struct` is created by the [`overlapping`] method on [`RangeSet`]. See its
384 /// documentation for more.
385 ///
386 /// [`overlapping`]: RangeSet::overlapping
387 pub struct Overlappingrust-analyzer cargo rangemap 1.7.1 set/Overlapping#<'a, T, R: Borrowrust-analyzer cargo core https://github.com/rust-lang/rust/library/core borrow/Borrow#<Rangerust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#<T>> = &'a Rangerust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#<T>> {
388 innerrust-analyzer cargo rangemap 1.7.1 set/Overlapping#inner.: craterust-analyzer cargo rangemap 1.7.1 crate/::maprust-analyzer cargo rangemap 1.7.1 map/::Overlappingrust-analyzer cargo rangemap 1.7.1 map/Overlapping#<'a, T, (), R>,
389 }
390
391 // `Overlapping` is always fused. (See definition of `next` below.)
392 impl<'a, T, R: Borrowrust-analyzer cargo core https://github.com/rust-lang/rust/library/core borrow/Borrow#<Rangerust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#<T>>> corerust-analyzer cargo core https://github.com/rust-lang/rust/library/core crate/::iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/::FusedIteratorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/marker/FusedIterator# for Overlappingrust-analyzer cargo rangemap 1.7.1 set/Overlapping#<'a, T, R> where
393 T: Ordrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Ord# + Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone#
394 {
395 }
396
397 impl<'a, T, R: Borrowrust-analyzer cargo core https://github.com/rust-lang/rust/library/core borrow/Borrow#<Rangerust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#<T>>> Iteratorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator# for Overlappingrust-analyzer cargo rangemap 1.7.1 set/Overlapping#<'a, T, R>
398 where
399 T: Ordrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Ord# + Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone#,
400 {
401 type Itemrust-analyzer cargo rangemap 1.7.1 set/impl#[`Overlapping<'a, T, R>`][Iterator]Item# = &'a Rangerust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#<T>;
402
403 fn nextrust-analyzer cargo rangemap 1.7.1 set/impl#[`Overlapping<'a, T, R>`][Iterator]next().(&mut self) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<Selfrust-analyzer cargo rangemap 1.7.1 set/impl#[`Overlapping<'a, T, R>`][Iterator]::Itemrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#Item#> {
404 self.innerrust-analyzer cargo rangemap 1.7.1 set/Overlapping#inner..nextrust-analyzer cargo rangemap 1.7.1 map/impl#[`Overlapping<'a, K, V, R>`][Iterator]next().().maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]map().(|(k, _v)| k)
405 }
406 }
407
408 impl<'a, T, R: Borrowrust-analyzer cargo core https://github.com/rust-lang/rust/library/core borrow/Borrow#<Rangerust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#<T>>> DoubleEndedIteratorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/double_ended/DoubleEndedIterator# for Overlappingrust-analyzer cargo rangemap 1.7.1 set/Overlapping#<'a, T, R>
409 where
410 T: Ordrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Ord# + Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone#,
411 {
412 fn next_backrust-analyzer cargo rangemap 1.7.1 set/impl#[`Overlapping<'a, T, R>`][DoubleEndedIterator]next_back().(&mut self) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<Selfrust-analyzer cargo rangemap 1.7.1 set/impl#[`Overlapping<'a, T, R>`][DoubleEndedIterator]::Itemrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#Item#> {
413 self.innerrust-analyzer cargo rangemap 1.7.1 set/Overlapping#inner..next_backrust-analyzer cargo rangemap 1.7.1 map/impl#[`Overlapping<'a, K, V, R>`][DoubleEndedIterator]next_back().().maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]map().(|(k, _v)| k)
414 }
415 }
416
417 impl<T: Ordrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Ord# + Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone#> BitAndrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/BitAnd# for &RangeSetrust-analyzer cargo rangemap 1.7.1 set/RangeSet#<T> {
418 type Outputrust-analyzer cargo rangemap 1.7.1 set/impl#[`&RangeSet<T>`][`BitAnd<Self>`]Output# = RangeSetrust-analyzer cargo rangemap 1.7.1 set/RangeSet#<T>;
419
420 fn bitandrust-analyzer cargo rangemap 1.7.1 set/impl#[`&RangeSet<T>`][`BitAnd<Self>`]bitand().(self, other: Selfrust-analyzer cargo rangemap 1.7.1 set/impl#[`&RangeSet<T>`][`BitAnd<Self>`]) -> Selfrust-analyzer cargo rangemap 1.7.1 set/impl#[`&RangeSet<T>`][`BitAnd<Self>`]::Outputrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/BitAnd#Output# {
421 self.intersectionrust-analyzer cargo rangemap 1.7.1 set/impl#[`RangeSet<T>`]intersection().(other).collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().()
422 }
423 }
424
425 impl<T: Ordrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Ord# + Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone#> BitOrrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/BitOr# for &RangeSetrust-analyzer cargo rangemap 1.7.1 set/RangeSet#<T> {
426 type Outputrust-analyzer cargo rangemap 1.7.1 set/impl#[`&RangeSet<T>`][`BitOr<Self>`]Output# = RangeSetrust-analyzer cargo rangemap 1.7.1 set/RangeSet#<T>;
427
428 fn bitorrust-analyzer cargo rangemap 1.7.1 set/impl#[`&RangeSet<T>`][`BitOr<Self>`]bitor().(self, other: Selfrust-analyzer cargo rangemap 1.7.1 set/impl#[`&RangeSet<T>`][`BitOr<Self>`]) -> Selfrust-analyzer cargo rangemap 1.7.1 set/impl#[`&RangeSet<T>`][`BitOr<Self>`]::Outputrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/BitOr#Output# {
429 self.unionrust-analyzer cargo rangemap 1.7.1 set/impl#[`RangeSet<T>`]union().(other).collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().()
430 }
431 }
432
433 impl<T: Ordrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Ord# + Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone#, const N: usize> Fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/From#<[Rangerust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#<T>; N]> for RangeSetrust-analyzer cargo rangemap 1.7.1 set/RangeSet#<T> {
434 fn fromrust-analyzer cargo rangemap 1.7.1 set/impl#[`RangeSet<T>`][`From<[Range<T>; N]>`]from().(value: [Rangerust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#<T>; N]) -> Selfrust-analyzer cargo rangemap 1.7.1 set/impl#[`RangeSet<T>`][`From<[Range<T>; N]>`] {
435 let mut set = Selfrust-analyzer cargo rangemap 1.7.1 set/impl#[`RangeSet<T>`][`From<[Range<T>; N]>`]::newrust-analyzer cargo rangemap 1.7.1 set/impl#[`RangeSet<T>`]new().();
436 for value in IntoIteratorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/collect/IntoIterator#::into_iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/iter/impl#[`[T; N]`][IntoIterator]into_iter().(value) {
437 set.insertrust-analyzer cargo rangemap 1.7.1 set/impl#[`RangeSet<T>`]insert().(value);
438 }
439 set
440 }
441 }
442
443 /// Create a [`RangeSet`] from a list of ranges.
444 ///
445 /// # Example
446 ///
447 /// ```rust
448 /// # use rangemap::range_set;
449 /// let set = range_set![0..100, 200..300, 400..500];
450 /// ```
451 #[macro_export]
452 macro_rules! range_setrust-analyzer cargo rangemap 1.7.1 set/range_set! {
453 ($($range:expr),* $(,)?) => {{
454 $crate::RangeSet::from([$($range),*])
455 }};
456 }
457
458 #[cfg(test)]
459 mod testsrust-analyzer cargo rangemap 1.7.1 set/tests/ {
460 use superrust-analyzer cargo rangemap 1.7.1 set/::*;
461 use allocrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc crate/ as stdrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc crate/;
462 use allocrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc crate/::{formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!, vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/, vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/::Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#};
•463 //use proptest::prelude::*;
464 //use test_strategy::proptest;
465
•466 /*impl<T> Arbitrary for RangeSet<T>
467 where
468 T: Ord + Clone + Debug + Arbitrary + 'static,
469 {
470 type Parameters = ();
471 type Strategy = BoxedStrategy<Self>;
472
473 fn arbitrary_with(_parameters: Self::Parameters) -> Self::Strategy {
474 any::<Vec<Range<T>>>()
475 .prop_map(|ranges| {
476 ranges
477 .into_iter()
478 .filter(|range| range.start != range.end)
479 .collect::<RangeSet<T>>()
480 })
481 .boxed()
482 }
•483 }*/
484
•485 /*#[proptest]
486 fn test_first(set: RangeSet<u64>) {
487 assert_eq!(set.first(), set.iter().min_by_key(|range| range.start));
488 }
489
490 #[proptest]
491 #[allow(clippy::len_zero)]
492 fn test_len(mut map: RangeSet<u64>) {
493 assert_eq!(map.len(), map.iter().count());
494 assert_eq!(map.is_empty(), map.len() == 0);
495 map.clear();
496 assert_eq!(map.len(), 0);
497 assert!(map.is_empty());
498 assert_eq!(map.iter().count(), 0);
499 }
500
501 #[proptest]
502 fn test_last(set: RangeSet<u64>) {
503 assert_eq!(set.last(), set.iter().max_by_key(|range| range.end));
504 }
505
506 #[proptest]
507 fn test_iter_reversible(set: RangeSet<u64>) {
508 let forward: Vec<_> = set.iter().collect();
509 let mut backward: Vec<_> = set.iter().rev().collect();
510 backward.reverse();
511 assert_eq!(forward, backward);
512 }
513
514 #[proptest]
515 fn test_into_iter_reversible(set: RangeSet<u64>) {
516 let forward: Vec<_> = set.clone().into_iter().collect();
517 let mut backward: Vec<_> = set.into_iter().rev().collect();
518 backward.reverse();
519 assert_eq!(forward, backward);
520 }
521
522 #[proptest]
523 fn test_overlapping_reversible(set: RangeSet<u64>, range: Range<u64>) {
524 let forward: Vec<_> = set.overlapping(&range).collect();
525 let mut backward: Vec<_> = set.overlapping(&range).rev().collect();
526 backward.reverse();
527 assert_eq!(forward, backward);
•528 }*/
529
530 // neccessary due to assertion on empty ranges
531 fn filter_rangesrust-analyzer cargo rangemap 1.7.1 set/tests/filter_ranges().<T: Ordrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Ord#>(ranges: Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<Rangerust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#<T>>) -> Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<Rangerust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#<T>> {
532 ranges
533 .into_iterrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][IntoIterator]into_iter().()
534 .filterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#filter().(|range| range.startrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#start. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq#ne().!=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq#ne(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq#ne().range.endrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#end.)
535 .collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().()
536 }
537
•538 /*#[proptest]
539 fn test_arbitrary_set_u8(ranges: Vec<Range<u8>>) {
540 let ranges = filter_ranges(ranges);
541 let set = ranges.iter().fold(RangeSet::new(), |mut set, range| {
542 set.insert(range.clone());
543 set
544 });
545
546 for value in 0..u8::MAX {
547 assert_eq!(
548 set.contains(&value),
549 ranges.iter().any(|range| range.contains(&value))
550 );
551 }
552 }
553
554 #[proptest]
555 #[allow(deprecated)]
556 fn test_hash(left: RangeSet<u64>, right: RangeSet<u64>) {
557 use core::hash::{Hash, Hasher, SipHasher};
558
559 let hash = |set: &RangeSet<_>| {
560 let mut hasher = SipHasher::new();
561 set.hash(&mut hasher);
562 hasher.finish()
563 };
564
565 if left == right {
566 assert!(
567 hash(&left) == hash(&right),
568 "if two values are equal, their hash must be equal"
569 );
570 }
571
572 // if the hashes are equal the values might not be the same (collision)
573 if hash(&left) != hash(&right) {
574 assert!(
575 left != right,
576 "if two value's hashes are not equal, they must not be equal"
577 );
578 }
579 }
580
581 #[proptest]
582 fn test_ord(left: RangeSet<u64>, right: RangeSet<u64>) {
583 assert_eq!(
584 left == right,
585 left.cmp(&right).is_eq(),
586 "ordering and equality must match"
587 );
588 assert_eq!(
589 left.cmp(&right),
590 left.partial_cmp(&right).unwrap(),
591 "ordering is total for ordered parameters"
592 );
•593 }*/
594
595 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
596 fn test_from_arrayrust-analyzer cargo rangemap 1.7.1 set/tests/test_from_array().() {
597 let mut set = RangeSetrust-analyzer cargo rangemap 1.7.1 set/RangeSet#::newrust-analyzer cargo rangemap 1.7.1 set/impl#[`RangeSet<T>`]new().();
598 set.insertrust-analyzer cargo rangemap 1.7.1 set/impl#[`RangeSet<T>`]insert().(0..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#100);
599 set.insertrust-analyzer cargo rangemap 1.7.1 set/impl#[`RangeSet<T>`]insert().(200..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#300);
600 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(set, RangeSetrust-analyzer cargo rangemap 1.7.1 set/RangeSet#::fromrust-analyzer cargo rangemap 1.7.1 set/impl#[`RangeSet<T>`][`From<[Range<T>; N]>`]from().([0..100, 200..300]));
601 }
602
603 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
604 fn test_macrorust-analyzer cargo rangemap 1.7.1 set/tests/test_macro().() {
605 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(range_setrust-analyzer cargo rangemap 1.7.1 set/range_set!![], RangeSetrust-analyzer cargo rangemap 1.7.1 set/RangeSet#::<i64>::newrust-analyzer cargo rangemap 1.7.1 set/impl#[`RangeSet<T>`]new().());
606 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(
607 range_setrust-analyzer cargo rangemap 1.7.1 set/range_set!![0..100, 200..300, 400..500],
608 [0..100, 200..300, 400..500].iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter().().clonedrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#cloned().().collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().(),
609 );
610 }
611
•612 /*#[proptest]
613 fn test_union_overlaps_u8(left: RangeSet<u8>, right: RangeSet<u8>) {
614 let mut union = RangeSet::new();
615 for range in left.union(&right) {
616 // there should not be any overlaps in the ranges returned by the union
617 assert!(union.overlapping(&range).next().is_none());
618 union.insert(range);
619 }
620 }
621
622 #[proptest]
623 fn test_union_contains_u8(left: RangeSet<u8>, right: RangeSet<u8>) {
624 let union = (&left) | (&right);
625
626 // value should be in the union if and only if it is in either set
627 for value in 0..u8::MAX {
628 assert_eq!(
629 union.contains(&value),
630 left.contains(&value) || right.contains(&value)
631 );
632 }
633 }
634
635 #[proptest]
636 fn test_intersection_contains_u8(left: RangeSet<u8>, right: RangeSet<u8>) {
637 let intersection = (&left) & (&right);
638
639 // value should be in the intersection if and only if it is in both sets
640 for value in 0..u8::MAX {
641 assert_eq!(
642 intersection.contains(&value),
643 left.contains(&value) && right.contains(&value)
644 );
645 }
646 }
647
648 #[proptest]
649 fn test_intersection_overlaps_u8(left: RangeSet<u8>, right: RangeSet<u8>) {
650 let mut union = RangeSet::new();
651 for range in left.intersection(&right) {
652 // there should not be any overlaps in the ranges returned by the
653 // intersection
654 assert!(union.overlapping(&range).next().is_none());
655 union.insert(range);
656 }
•657 }*/
658
659 trait RangeSetExtrust-analyzer cargo rangemap 1.7.1 set/tests/RangeSetExt#<T> {
660 fn to_vecrust-analyzer cargo rangemap 1.7.1 set/tests/RangeSetExt#to_vec().(&self) -> Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<Rangerust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#<T>>;
661 }
662
663 impl<T> RangeSetExtrust-analyzer cargo rangemap 1.7.1 set/tests/RangeSetExt#<T> for RangeSetrust-analyzer cargo rangemap 1.7.1 set/RangeSet#<T>
664 where
665 T: Ordrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Ord# + Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone#,
666 {
667 fn to_vecrust-analyzer cargo rangemap 1.7.1 set/tests/impl#[`RangeSet<T>`][`RangeSetExt<T>`]to_vec().(&self) -> Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<Rangerust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#<T>> {
668 self.iterrust-analyzer cargo rangemap 1.7.1 set/impl#[`RangeSet<T>`]iter().().clonedrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#cloned().().collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().()
669 }
670 }
671
672 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
673 fn empty_set_is_emptyrust-analyzer cargo rangemap 1.7.1 set/tests/empty_set_is_empty().() {
674 let range_set: RangeSetrust-analyzer cargo rangemap 1.7.1 set/RangeSet#<u32> = RangeSetrust-analyzer cargo rangemap 1.7.1 set/RangeSet#::newrust-analyzer cargo rangemap 1.7.1 set/impl#[`RangeSet<T>`]new().();
675 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(range_set.to_vecrust-analyzer cargo rangemap 1.7.1 set/tests/impl#[`RangeSet<T>`][`RangeSetExt<T>`]to_vec().(), vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![]);
676 }
677
678 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
679 fn insert_into_empty_maprust-analyzer cargo rangemap 1.7.1 set/tests/insert_into_empty_map().() {
680 let mut range_set: RangeSetrust-analyzer cargo rangemap 1.7.1 set/RangeSet#<u32> = RangeSetrust-analyzer cargo rangemap 1.7.1 set/RangeSet#::newrust-analyzer cargo rangemap 1.7.1 set/impl#[`RangeSet<T>`]new().();
681 range_set.insertrust-analyzer cargo rangemap 1.7.1 set/impl#[`RangeSet<T>`]insert().(0..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#50);
682 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(range_set.to_vecrust-analyzer cargo rangemap 1.7.1 set/tests/impl#[`RangeSet<T>`][`RangeSetExt<T>`]to_vec().(), vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![0..50]);
683 }
684
685 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
686 fn remove_partially_overlappingrust-analyzer cargo rangemap 1.7.1 set/tests/remove_partially_overlapping().() {
687 let mut range_set: RangeSetrust-analyzer cargo rangemap 1.7.1 set/RangeSet#<u32> = RangeSetrust-analyzer cargo rangemap 1.7.1 set/RangeSet#::newrust-analyzer cargo rangemap 1.7.1 set/impl#[`RangeSet<T>`]new().();
688 range_set.insertrust-analyzer cargo rangemap 1.7.1 set/impl#[`RangeSet<T>`]insert().(0..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#50);
689 range_set.removerust-analyzer cargo rangemap 1.7.1 set/impl#[`RangeSet<T>`]remove().(25..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#75);
690 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(range_set.to_vecrust-analyzer cargo rangemap 1.7.1 set/tests/impl#[`RangeSet<T>`][`RangeSetExt<T>`]to_vec().(), vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![0..25]);
691 }
692
693 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
694 fn gaps_between_items_floating_inside_outer_rangerust-analyzer cargo rangemap 1.7.1 set/tests/gaps_between_items_floating_inside_outer_range().() {
695 let mut range_set: RangeSetrust-analyzer cargo rangemap 1.7.1 set/RangeSet#<u32> = RangeSetrust-analyzer cargo rangemap 1.7.1 set/RangeSet#::newrust-analyzer cargo rangemap 1.7.1 set/impl#[`RangeSet<T>`]new().();
696 // 0 1 2 3 4 5 6 7 8 9
697 // ◌ ◌ ◌ ◌ ◌ ●-◌ ◌ ◌ ◌
698 range_set.insertrust-analyzer cargo rangemap 1.7.1 set/impl#[`RangeSet<T>`]insert().(5..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#6);
699 // 0 1 2 3 4 5 6 7 8 9
700 // ◌ ◌ ◌ ●-◌ ◌ ◌ ◌ ◌ ◌
701 range_set.insertrust-analyzer cargo rangemap 1.7.1 set/impl#[`RangeSet<T>`]insert().(3..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#4);
702 // 0 1 2 3 4 5 6 7 8 9
703 // ◌ ◆-------------◇ ◌
704 let outer_range = 1..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#8;
705 let mut gaps = range_set.gapsrust-analyzer cargo rangemap 1.7.1 set/impl#[`RangeSet<T>`]gaps().(&outer_range);
706 // Should yield gaps at start, between items,
707 // and at end.
708 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(gaps.nextrust-analyzer cargo rangemap 1.7.1 set/impl#[`Gaps<'a, T>`][Iterator]next().(), Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(1..3));
709 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(gaps.nextrust-analyzer cargo rangemap 1.7.1 set/impl#[`Gaps<'a, T>`][Iterator]next().(), Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(4..5));
710 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(gaps.nextrust-analyzer cargo rangemap 1.7.1 set/impl#[`Gaps<'a, T>`][Iterator]next().(), Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(6..8));
711 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(gaps.nextrust-analyzer cargo rangemap 1.7.1 set/impl#[`Gaps<'a, T>`][Iterator]next().(), Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#);
712 // Gaps iterator should be fused.
713 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(gaps.nextrust-analyzer cargo rangemap 1.7.1 set/impl#[`Gaps<'a, T>`][Iterator]next().(), Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#);
714 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(gaps.nextrust-analyzer cargo rangemap 1.7.1 set/impl#[`Gaps<'a, T>`][Iterator]next().(), Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#);
715 }
716
717 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
718 fn overlapping_partial_edges_complete_middlerust-analyzer cargo rangemap 1.7.1 set/tests/overlapping_partial_edges_complete_middle().() {
719 let mut range_map: RangeSetrust-analyzer cargo rangemap 1.7.1 set/RangeSet#<u32> = RangeSetrust-analyzer cargo rangemap 1.7.1 set/RangeSet#::newrust-analyzer cargo rangemap 1.7.1 set/impl#[`RangeSet<T>`]new().();
720
721 // 0 1 2 3 4 5 6 7 8 9
722 // ●---◌ ◌ ◌ ◌ ◌ ◌ ◌ ◌
723 range_map.insertrust-analyzer cargo rangemap 1.7.1 set/impl#[`RangeSet<T>`]insert().(0..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#2);
724 // 0 1 2 3 4 5 6 7 8 9
725 // ◌ ◌ ◌ ●-◌ ◌ ◌ ◌ ◌ ◌
726 range_map.insertrust-analyzer cargo rangemap 1.7.1 set/impl#[`RangeSet<T>`]insert().(3..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#4);
727 // 0 1 2 3 4 5 6 7 8 9
728 // ◌ ◌ ◌ ◌ ◌ ●---◌ ◌ ◌
729 range_map.insertrust-analyzer cargo rangemap 1.7.1 set/impl#[`RangeSet<T>`]insert().(5..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#7);
730
731 // 0 1 2 3 4 5 6 7 8 9
732 // ◌ ◆---------◇ ◌ ◌ ◌
733 let query_range = 1..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#6;
734
735 let mut overlapping = range_map.overlappingrust-analyzer cargo rangemap 1.7.1 set/impl#[`RangeSet<T>`]overlapping().(&query_range);
736
737 // Should yield partially overlapped range at start.
738 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(overlapping.nextrust-analyzer cargo rangemap 1.7.1 set/impl#[`Overlapping<'a, T, R>`][Iterator]next().(), Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(&(0..2)));
739 // Should yield completely overlapped range in middle.
740 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(overlapping.nextrust-analyzer cargo rangemap 1.7.1 set/impl#[`Overlapping<'a, T, R>`][Iterator]next().(), Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(&(3..4)));
741 // Should yield partially overlapped range at end.
742 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(overlapping.nextrust-analyzer cargo rangemap 1.7.1 set/impl#[`Overlapping<'a, T, R>`][Iterator]next().(), Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(&(5..7)));
743 // Gaps iterator should be fused.
744 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(overlapping.nextrust-analyzer cargo rangemap 1.7.1 set/impl#[`Overlapping<'a, T, R>`][Iterator]next().(), Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#);
745 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(overlapping.nextrust-analyzer cargo rangemap 1.7.1 set/impl#[`Overlapping<'a, T, R>`][Iterator]next().(), Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#);
746 }
747
748 ///
749 /// impl Debug
750 ///
751
752 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
753 fn set_debug_repr_looks_rightrust-analyzer cargo rangemap 1.7.1 set/tests/set_debug_repr_looks_right().() {
754 let mut set: RangeSetrust-analyzer cargo rangemap 1.7.1 set/RangeSet#<u32> = RangeSetrust-analyzer cargo rangemap 1.7.1 set/RangeSet#::newrust-analyzer cargo rangemap 1.7.1 set/impl#[`RangeSet<T>`]new().();
755
756 // Empty
757 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!("{:?}", set), "{}");
758
759 // One entry
760 set.insertrust-analyzer cargo rangemap 1.7.1 set/impl#[`RangeSet<T>`]insert().(2..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#5);
761 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!("{:?}", set), "{2..5}");
762
763 // Many entries
764 set.insertrust-analyzer cargo rangemap 1.7.1 set/impl#[`RangeSet<T>`]insert().(7..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#8);
765 set.insertrust-analyzer cargo rangemap 1.7.1 set/impl#[`RangeSet<T>`]insert().(10..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#11);
766 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!("{:?}", set), "{2..5, 7..8, 10..11}");
767 }
768
769 // impl Default where T: ?Default
770
771 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
772 fn always_defaultrust-analyzer cargo rangemap 1.7.1 set/tests/always_default().() {
773 struct NoDefaultrust-analyzer cargo rangemap 1.7.1 set/tests/NoDefault#;
774 RangeSetrust-analyzer cargo rangemap 1.7.1 set/RangeSet#::<NoDefaultrust-analyzer cargo rangemap 1.7.1 set/tests/NoDefault#>::defaultrust-analyzer cargo rangemap 1.7.1 set/impl#[`RangeSet<T>`][Default]default().();
775 }
776
777 // impl Serialize
778
779 #[cfg(feature = "serde1")]
780 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
781 fn serializationrust-analyzer cargo rangemap 1.7.1 set/tests/serialization().() {
782 let mut range_set: RangeSetrust-analyzer cargo rangemap 1.7.1 set/RangeSet#<u32> = RangeSetrust-analyzer cargo rangemap 1.7.1 set/RangeSet#::newrust-analyzer cargo rangemap 1.7.1 set/impl#[`RangeSet<T>`]new().();
783 // 0 1 2 3 4 5 6 7 8 9
784 // ◌ ◆---◇ ◌ ◌ ◌ ◌ ◌ ◌
785 range_set.insertrust-analyzer cargo rangemap 1.7.1 set/impl#[`RangeSet<T>`]insert().(1..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#3);
786 // 0 1 2 3 4 5 6 7 8 9
787 // ◌ ◌ ◌ ◌ ◌ ◆---◇ ◌ ◌
788 range_set.insertrust-analyzer cargo rangemap 1.7.1 set/impl#[`RangeSet<T>`]insert().(5..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#7);
789 let output = serde_jsonrust-analyzer cargo serde_json 1.0.143 crate/::to_stringrust-analyzer cargo serde_json 1.0.143 ser/to_string().(&range_set).expectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]expect().("Failed to serialize");
790 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(output, "[[1,3],[5,7]]");
791 }
792
793 // impl Deserialize
794
795 #[cfg(feature = "serde1")]
796 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
797 fn deserializationrust-analyzer cargo rangemap 1.7.1 set/tests/deserialization().() {
798 let input = "[[1,3],[5,7]]";
799 let range_set: RangeSetrust-analyzer cargo rangemap 1.7.1 set/RangeSet#<u32> = serde_jsonrust-analyzer cargo serde_json 1.0.143 crate/::from_strrust-analyzer cargo serde_json 1.0.143 de/from_str().(input).expectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]expect().("Failed to deserialize");
800 let reserialized = serde_jsonrust-analyzer cargo serde_json 1.0.143 crate/::to_stringrust-analyzer cargo serde_json 1.0.143 ser/to_string().(&range_set).expectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]expect().("Failed to re-serialize");
801 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(reserialized, input);
802 }
803
804 // const fn
805
806 #[cfg(feature = "const_fn")]
807 const _SETrust-analyzer cargo rangemap 1.7.1 set/tests/_SET.: RangeSetrust-analyzer cargo rangemap 1.7.1 set/RangeSet#<u32> = RangeSetrust-analyzer cargo rangemap 1.7.1 set/RangeSet#::newrust-analyzer cargo rangemap 1.7.1 set/impl#[`RangeSet<T>`]new().();
808
809 #[cfg(feature = "quickcheck")]
810 quickcheckrust-analyzer cargo quickcheck 1.0.3 crate/::quickcheckrust-analyzer cargo quickcheck 1.0.3 quickcheck!! {
811 fn proprust-analyzer cargo rangemap 1.7.1 set/tests/prop().(xs: RangeSetrust-analyzer cargo rangemap 1.7.1 set/RangeSet#<usize>) -> bool {
812 xs == xs
813 }
814 }
815 }