Debian Codegraph @

src/map.rs

raw symbols ◀ ▶ SCIP
2 Debian patches touch this file
1 use superrust-analyzer cargo rangemap 1.7.1 crate/::range_wrapperrust-analyzer cargo rangemap 1.7.1 range_wrapper/::RangeStartWrapperrust-analyzer cargo rangemap 1.7.1 range_wrapper/RangeStartWrapper#;
2 use craterust-analyzer cargo rangemap 1.7.1 crate/::range_wrapperrust-analyzer cargo rangemap 1.7.1 range_wrapper/::RangeEndWrapperrust-analyzer cargo rangemap 1.7.1 range_wrapper/RangeEndWrapper#;
3 use craterust-analyzer cargo rangemap 1.7.1 crate/::std_extrust-analyzer cargo rangemap 1.7.1 std_ext/::*;
4 use allocrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc crate/::collectionsrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/::BTreeMaprust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/btree/map/BTreeMap#;
5 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#;
6 use corerust-analyzer cargo core https://github.com/rust-lang/rust/library/core crate/::cmprust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/::Orderingrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Ordering#;
7 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#};
8 use corerust-analyzer cargo core https://github.com/rust-lang/rust/library/core crate/::hashrust-analyzer cargo core https://github.com/rust-lang/rust/library/core hash/::Hashrust-analyzer cargo core https://github.com/rust-lang/rust/library/core hash/Hash#;
9 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/::{DoubleEndedIteratorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/double_ended/DoubleEndedIterator#, FromIteratorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/collect/FromIterator#};
10 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/::{Boundrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Bound#, Rangerust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#};
11 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/::*;
12
13 #[cfg(feature = "serde1")]
14 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#;
15 #[cfg(feature = "serde1")]
16 use serderust-analyzer cargo serde 1.0.219 crate/::{
17 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#},
18 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#},
19 };
20
21 /// A map whose keys are stored as (half-open) ranges bounded
22 /// inclusively below and exclusively above `(start..end)`.
23 ///
24 /// Contiguous and overlapping ranges that map to the same value
25 /// are coalesced into a single range.
26 #[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:, Eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Eq:)]
27 pub struct RangeMaprust-analyzer cargo rangemap 1.7.1 map/RangeMap#<K, V> {
28 // Wrap ranges so that they are `Ord`.
29 // See `range_wrapper.rs` for explanation.
30 pub(craterust-analyzer cargo rangemap 1.7.1 crate/) btmrust-analyzer cargo rangemap 1.7.1 map/RangeMap#btm.: BTreeMaprust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/btree/map/BTreeMap#<RangeStartWrapperrust-analyzer cargo rangemap 1.7.1 range_wrapper/RangeStartWrapper#<K>, V>,
31 }
32
33 impl<K, V> Defaultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core default/Default# for RangeMaprust-analyzer cargo rangemap 1.7.1 map/RangeMap#<K, V> {
34 fn defaultrust-analyzer cargo rangemap 1.7.1 map/impl#[`RangeMap<K, V>`][Default]default().() -> Selfrust-analyzer cargo rangemap 1.7.1 map/impl#[`RangeMap<K, V>`][Default] {
35 Selfrust-analyzer cargo rangemap 1.7.1 map/impl#[`RangeMap<K, V>`][Default] {
36 btmrust-analyzer cargo rangemap 1.7.1 map/RangeMap#btm.: BTreeMaprust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/btree/map/BTreeMap#::defaultrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/btree/map/impl#[`BTreeMap<K, V>`][Default]default().(),
37 }
38 }
39 }
40
41 impl<K, V> Hashrust-analyzer cargo core https://github.com/rust-lang/rust/library/core hash/Hash# for RangeMaprust-analyzer cargo rangemap 1.7.1 map/RangeMap#<K, V>
42 where
43 K: Hashrust-analyzer cargo core https://github.com/rust-lang/rust/library/core hash/Hash#,
44 V: Hashrust-analyzer cargo core https://github.com/rust-lang/rust/library/core hash/Hash#,
45 {
46 fn hashrust-analyzer cargo rangemap 1.7.1 map/impl#[`RangeMap<K, V>`][Hash]hash().<H: corerust-analyzer cargo core https://github.com/rust-lang/rust/library/core crate/::hashrust-analyzer cargo core https://github.com/rust-lang/rust/library/core hash/::Hasherrust-analyzer cargo core https://github.com/rust-lang/rust/library/core hash/Hasher#>(&self, state: &mut H) {
47 state.write_usizerust-analyzer cargo core https://github.com/rust-lang/rust/library/core hash/Hasher#write_usize().(self.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().());
48 for elt in self.iterrust-analyzer cargo rangemap 1.7.1 map/impl#[`RangeMap<K, V>`]iter().() {
49 elt.hashrust-analyzer cargo core https://github.com/rust-lang/rust/library/core hash/impls/impl#[`(T, B)`][Hash]hash().(state);
50 }
51 }
52 }
53
54 impl<K, V> PartialEqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq# for RangeMaprust-analyzer cargo rangemap 1.7.1 map/RangeMap#<K, V>
55 where
56 K: PartialEqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq#,
57 V: PartialEqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq#,
58 {
59 fn eqrust-analyzer cargo rangemap 1.7.1 map/impl#[`RangeMap<K, V>`][`PartialEq<Self>`]eq().(&self, other: &RangeMaprust-analyzer cargo rangemap 1.7.1 map/RangeMap#<K, V>) -> bool {
60 self.iterrust-analyzer cargo rangemap 1.7.1 map/impl#[`RangeMap<K, V>`]iter().().eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#eq().(other.iterrust-analyzer cargo rangemap 1.7.1 map/impl#[`RangeMap<K, V>`]iter().())
61 }
62 }
63
64 impl<K, V> PartialOrdrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialOrd# for RangeMaprust-analyzer cargo rangemap 1.7.1 map/RangeMap#<K, V>
65 where
66 K: PartialOrdrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialOrd#,
67 V: PartialOrdrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialOrd#,
68 {
69 #[inline]
70 fn partial_cmprust-analyzer cargo rangemap 1.7.1 map/impl#[`RangeMap<K, V>`][`PartialOrd<Self>`]partial_cmp().(&self, other: &RangeMaprust-analyzer cargo rangemap 1.7.1 map/RangeMap#<K, V>) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<Orderingrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Ordering#> {
71 self.expanded_iterrust-analyzer cargo rangemap 1.7.1 map/impl#[`RangeMap<K, V>`]expanded_iter().().partial_cmprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#partial_cmp().(other.expanded_iterrust-analyzer cargo rangemap 1.7.1 map/impl#[`RangeMap<K, V>`]expanded_iter().())
72 }
73 }
74
75 impl<K, V> Ordrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Ord# for RangeMaprust-analyzer cargo rangemap 1.7.1 map/RangeMap#<K, V>
76 where
77 K: Ordrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Ord#,
78 V: Ordrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Ord#,
79 {
80 #[inline]
81 fn cmprust-analyzer cargo rangemap 1.7.1 map/impl#[`RangeMap<K, V>`][Ord]cmp().(&self, other: &RangeMaprust-analyzer cargo rangemap 1.7.1 map/RangeMap#<K, V>) -> Orderingrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Ordering# {
82 self.expanded_iterrust-analyzer cargo rangemap 1.7.1 map/impl#[`RangeMap<K, V>`]expanded_iter().().cmprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#cmp().(other.expanded_iterrust-analyzer cargo rangemap 1.7.1 map/impl#[`RangeMap<K, V>`]expanded_iter().())
83 }
84 }
85
86 #[cfg(feature = "quickcheck")]
87 impl<K, V> quickcheckrust-analyzer cargo quickcheck 1.0.3 crate/::Arbitraryrust-analyzer cargo quickcheck 1.0.3 arbitrary/Arbitrary# for RangeMaprust-analyzer cargo rangemap 1.7.1 map/RangeMap#<K, V>
88 where
89 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#,
90 V: quickcheckrust-analyzer cargo quickcheck 1.0.3 crate/::Arbitraryrust-analyzer cargo quickcheck 1.0.3 arbitrary/Arbitrary# + PartialEqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq#,
91 {
92 fn arbitraryrust-analyzer cargo rangemap 1.7.1 map/impl#[`RangeMap<K, V>`][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 map/impl#[`RangeMap<K, V>`][Arbitrary] {
93 // REVISIT: allocation could be avoided if Gen::gen_size were public (https://github.com/BurntSushi/quickcheck/issues/326#issue-2653601170)
94 <allocrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc crate/::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#<(Rangerust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#<_>, _)>>::arbitraryrust-analyzer cargo quickcheck 1.0.3 arbitrary/impl#[`Vec<A>`][Arbitrary]arbitrary().(g)
95 .into_iterrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][IntoIterator]into_iter().()
96 .filterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#filter().(|(range, _)| !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().range.is_emptyrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/impl#[`Range<Idx>`]is_empty().())
97 .collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().()
98 }
99 }
100
101 impl<K, V> RangeMaprust-analyzer cargo rangemap 1.7.1 map/RangeMap#<K, V> {
102 /// Makes a new empty `RangeMap`.
103 #[cfg(feature = "const_fn")]
104 pub const fn newrust-analyzer cargo rangemap 1.7.1 map/impl#[`RangeMap<K, V>`]new().() -> Selfrust-analyzer cargo rangemap 1.7.1 map/impl#[`RangeMap<K, V>`] {
105 RangeMaprust-analyzer cargo rangemap 1.7.1 map/RangeMap# {
106 btmrust-analyzer cargo rangemap 1.7.1 map/RangeMap#btm.: BTreeMaprust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/btree/map/BTreeMap#::newrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/btree/map/impl#[`BTreeMap<K, V>`]new().(),
107 }
108 }
109
110 /// Makes a new empty `RangeMap`.
111 #[cfg(not(feature = "const_fn"))]
112 pub fn new() -> Selfrust-analyzer cargo rangemap 1.7.1 map/impl#[`RangeMap<K, V>`] {
113 RangeMaprust-analyzer cargo rangemap 1.7.1 map/RangeMap# {
114 btm: BTreeMaprust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/btree/map/BTreeMap#::new(),
115 }
116 }
117
118 /// Gets an iterator over all pairs of key range and value,
119 /// ordered by key range.
120 ///
121 /// The iterator element type is `(&'a Range<K>, &'a V)`.
122 pub fn iterrust-analyzer cargo rangemap 1.7.1 map/impl#[`RangeMap<K, V>`]iter().(&self) -> Iterrust-analyzer cargo rangemap 1.7.1 map/Iter#<'_, K, V> {
123 Iterrust-analyzer cargo rangemap 1.7.1 map/Iter# {
124 innerrust-analyzer cargo rangemap 1.7.1 map/Iter#inner.: self.btmrust-analyzer cargo rangemap 1.7.1 map/RangeMap#btm..iterrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/btree/map/impl#[`BTreeMap<K, V, A>`]iter().(),
125 }
126 }
127
128 /// Clears the map, removing all elements.
129 pub fn clearrust-analyzer cargo rangemap 1.7.1 map/impl#[`RangeMap<K, V>`]clear().(&mut self) {
130 self.btmrust-analyzer cargo rangemap 1.7.1 map/RangeMap#btm..clearrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/btree/map/impl#[`BTreeMap<K, V, A>`]clear().();
131 }
132
133 /// Returns the number of elements in the map.
134 pub fn lenrust-analyzer cargo rangemap 1.7.1 map/impl#[`RangeMap<K, V>`]len().(&self) -> usize {
135 self.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().()
136 }
137
138 /// Returns true if the map contains no elements.
139 pub fn is_emptyrust-analyzer cargo rangemap 1.7.1 map/impl#[`RangeMap<K, V>`]is_empty().(&self) -> bool {
140 self.btmrust-analyzer cargo rangemap 1.7.1 map/RangeMap#btm..is_emptyrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/btree/map/impl#[`BTreeMap<K, V, A>`]is_empty().()
141 }
142
143 /// Returns an iterator that includes both ends of the key range.
144 ///
145 /// Mainly used for comparisons.
146 fn expanded_iterrust-analyzer cargo rangemap 1.7.1 map/impl#[`RangeMap<K, V>`]expanded_iter().(&self) -> impl Iteratorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#<Itemrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#Item# = (&K, &K, &V)> {
147 self.btmrust-analyzer cargo rangemap 1.7.1 map/RangeMap#btm..iterrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/btree/map/impl#[`BTreeMap<K, V, A>`]iter().().maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#map().(|(k, v)| (&k.startrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#start., &k.endrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#end., v))
148 }
149 }
150
151 impl<K, V> RangeMaprust-analyzer cargo rangemap 1.7.1 map/RangeMap#<K, V>
152 where
153 K: 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#,
154 {
155 /// Returns a reference to the value corresponding to the given key,
156 /// if the key is covered by any range in the map.
157 pub fn getrust-analyzer cargo rangemap 1.7.1 map/impl#[`RangeMap<K, V>`]get().(&self, key: &K) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<&V> {
158 self.get_key_valuerust-analyzer cargo rangemap 1.7.1 map/impl#[`RangeMap<K, V>`]get_key_value().(key).maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]map().(|(_range, value)| value)
159 }
160
161 /// Returns the range-value pair (as a pair of references) corresponding
162 /// to the given key, if the key is covered by any range in the map.
163 pub fn get_key_valuerust-analyzer cargo rangemap 1.7.1 map/impl#[`RangeMap<K, V>`]get_key_value().(&self, key: &K) -> 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#<K>, &V)> {
164 // The only stored range that could contain the given key is the
165 // last stored range whose start is less than or equal to this key.
166 let key_as_start = RangeStartWrapperrust-analyzer cargo rangemap 1.7.1 range_wrapper/RangeStartWrapper#::newrust-analyzer cargo rangemap 1.7.1 range_wrapper/impl#[`RangeStartWrapper<T>`]new().(key.clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone#clone().()..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#key.clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone#clone().());
167 self.btmrust-analyzer cargo rangemap 1.7.1 map/RangeMap#btm.
168 .rangerust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/btree/map/impl#[`BTreeMap<K, V, A>`]range().((Boundrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Bound#::Unboundedrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Bound#Unbounded#, Boundrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Bound#::Includedrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Bound#Included#(key_as_start)))
169 .next_backrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/btree/map/impl#[`Range<'a, K, V>`][DoubleEndedIterator]next_back().()
170 .filterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]filter().(|(start_wrapper, _value)| {
171 // Does the only candidate range contain
172 // the requested key?
173 start_wrapper.end_wrapperrust-analyzer cargo rangemap 1.7.1 range_wrapper/RangeStartWrapper#end_wrapper..rangerust-analyzer cargo rangemap 1.7.1 range_wrapper/RangeEndWrapper#range..containsrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/impl#[`Range<Idx>`]contains().(key)
174 })
175 .maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]map().(|(start_wrapper, value)| (&start_wrapper.end_wrapperrust-analyzer cargo rangemap 1.7.1 range_wrapper/RangeStartWrapper#end_wrapper..rangerust-analyzer cargo rangemap 1.7.1 range_wrapper/RangeEndWrapper#range., value))
176 }
177
178 /// Returns `true` if any range in the map covers the specified key.
179 pub fn contains_keyrust-analyzer cargo rangemap 1.7.1 map/impl#[`RangeMap<K, V>`]contains_key().(&self, key: &K) -> bool {
180 self.getrust-analyzer cargo rangemap 1.7.1 map/impl#[`RangeMap<K, V>`]get().(key).is_somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]is_some().()
181 }
182
183 /// Gets an iterator over all the maximally-sized ranges
184 /// contained in `outer_range` that are not covered by
185 /// any range stored in the map.
186 ///
187 /// If the start and end of the outer range are the same
188 /// and it does not overlap any stored range, then a single
189 /// empty gap will be returned.
190 ///
191 /// The iterator element type is `Range<K>`.
192 pub fn gapsrust-analyzer cargo rangemap 1.7.1 map/impl#[`RangeMap<K, V>`]gaps().<'a>(&'a self, outer_range: &'a Rangerust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#<K>) -> Gapsrust-analyzer cargo rangemap 1.7.1 map/Gaps#<'a, K, V> {
193 let overlap_iter = self.overlappingrust-analyzer cargo rangemap 1.7.1 map/impl#[`RangeMap<K, V>`]overlapping().(outer_range);
194 Gapsrust-analyzer cargo rangemap 1.7.1 map/Gaps# {
195 candidate_startrust-analyzer cargo rangemap 1.7.1 map/Gaps#candidate_start.: &outer_range.startrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#start.,
196 query_endrust-analyzer cargo rangemap 1.7.1 map/Gaps#query_end.: &outer_range.endrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#end.,
197 btm_range_iterrust-analyzer cargo rangemap 1.7.1 map/Gaps#btm_range_iter.: overlap_iter.btm_range_iterrust-analyzer cargo rangemap 1.7.1 map/Overlapping#btm_range_iter.,
198 }
199 }
200
201 /// Gets an iterator over all the stored ranges that are
202 /// either partially or completely overlapped by the given range.
203 pub fn overlappingrust-analyzer cargo rangemap 1.7.1 map/impl#[`RangeMap<K, V>`]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#<K>>>(&'_ self, range: R) -> Overlappingrust-analyzer cargo rangemap 1.7.1 map/Overlapping#<'_, K, V, R> {
204 // Find the first matching stored range by its _end_,
205 // using sneaky layering and `Borrow` implementation. (See `range_wrappers` module.)
206 let start_sliver =
207 RangeEndWrapperrust-analyzer cargo rangemap 1.7.1 range_wrapper/RangeEndWrapper#::newrust-analyzer cargo rangemap 1.7.1 range_wrapper/impl#[`RangeEndWrapper<T>`]new().(range.borrowrust-analyzer cargo core https://github.com/rust-lang/rust/library/core borrow/Borrow#borrow().().startrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#start..clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone#clone().()..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#range.borrowrust-analyzer cargo core https://github.com/rust-lang/rust/library/core borrow/Borrow#borrow().().startrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#start..clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone#clone().());
208 let btm_range_iter = self
209 .btmrust-analyzer cargo rangemap 1.7.1 map/RangeMap#btm.
210 .rangerust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/btree/map/impl#[`BTreeMap<K, V, A>`]range().::<RangeEndWrapperrust-analyzer cargo rangemap 1.7.1 range_wrapper/RangeEndWrapper#<K>, (Boundrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Bound#<&RangeEndWrapperrust-analyzer cargo rangemap 1.7.1 range_wrapper/RangeEndWrapper#<K>>, Boundrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Bound#<_>)>((
211 Boundrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Bound#::Excludedrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Bound#Excluded#(&start_sliver),
212 Boundrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Bound#::Unboundedrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Bound#Unbounded#,
213 ));
214 Overlappingrust-analyzer cargo rangemap 1.7.1 map/Overlapping# {
215 query_rangerust-analyzer cargo rangemap 1.7.1 map/Overlapping#query_range.: range,
216 btm_range_iterrust-analyzer cargo rangemap 1.7.1 map/Overlapping#btm_range_iter.,
217 }
218 }
219
220 /// Returns `true` if any range in the map completely or partially
221 /// overlaps the given range.
222 pub fn overlapsrust-analyzer cargo rangemap 1.7.1 map/impl#[`RangeMap<K, V>`]overlaps().(&self, range: &Rangerust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#<K>) -> bool {
223 self.overlappingrust-analyzer cargo rangemap 1.7.1 map/impl#[`RangeMap<K, V>`]overlapping().(range).nextrust-analyzer cargo rangemap 1.7.1 map/impl#[`Overlapping<'a, K, V, R>`][Iterator]next().().is_somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]is_some().()
224 }
225
226 /// Returns the first range-value pair in this map, if one exists. The range in this pair is the
227 /// minimum range in the map.
228 pub fn first_range_valuerust-analyzer cargo rangemap 1.7.1 map/impl#[`RangeMap<K, V>`]first_range_value().(&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#<K>, &V)> {
229 self.btmrust-analyzer cargo rangemap 1.7.1 map/RangeMap#btm.
230 .first_key_valuerust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/btree/map/impl#[`BTreeMap<K, V, A>`]first_key_value().()
231 .maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]map().(|(range, value)| (&range.end_wrapperrust-analyzer cargo rangemap 1.7.1 range_wrapper/RangeStartWrapper#end_wrapper..rangerust-analyzer cargo rangemap 1.7.1 range_wrapper/RangeEndWrapper#range., value))
232 }
233
234 /// Returns the last range-value pair in this map, if one exists. The range in this pair is the
235 /// maximum range in the map.
236 pub fn last_range_valuerust-analyzer cargo rangemap 1.7.1 map/impl#[`RangeMap<K, V>`]last_range_value().(&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#<K>, &V)> {
237 self.btmrust-analyzer cargo rangemap 1.7.1 map/RangeMap#btm.
238 .last_key_valuerust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/btree/map/impl#[`BTreeMap<K, V, A>`]last_key_value().()
239 .maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]map().(|(range, value)| (&range.end_wrapperrust-analyzer cargo rangemap 1.7.1 range_wrapper/RangeStartWrapper#end_wrapper..rangerust-analyzer cargo rangemap 1.7.1 range_wrapper/RangeEndWrapper#range., value))
240 }
241 }
242
243 impl<K, V> RangeMaprust-analyzer cargo rangemap 1.7.1 map/RangeMap#<K, V>
244 where
245 K: 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#,
246 V: PartialEqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq# + Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone#,
247 {
248 /// Insert a pair of key range and value into the map.
249 ///
250 /// If the inserted range partially or completely overlaps any
251 /// existing range in the map, then the existing range (or ranges) will be
252 /// partially or completely replaced by the inserted range.
253 ///
254 /// If the inserted range either overlaps or is immediately adjacent
255 /// any existing range _mapping to the same value_, then the ranges
256 /// will be coalesced into a single contiguous range.
257 ///
258 /// # Panics
259 ///
260 /// Panics if range `start >= end`.
261 pub fn insertrust-analyzer cargo rangemap 1.7.1 map/impl#[`RangeMap<K, V>`]insert().(&mut self, range: Rangerust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#<K>, value: V) {
262 // We don't want to have to make empty ranges make sense;
263 // they don't represent anything meaningful in this structure.
264 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(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/PartialOrd#lt(). range.endrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#end.);
265
266 // Wrap up the given range so that we can "borrow"
267 // it as a wrapper reference to either its start or end.
268 // See `range_wrapper.rs` for explanation of these hacks.
269 let mut new_start_wrapper: RangeStartWrapperrust-analyzer cargo rangemap 1.7.1 range_wrapper/RangeStartWrapper#<K> = RangeStartWrapperrust-analyzer cargo rangemap 1.7.1 range_wrapper/RangeStartWrapper#::newrust-analyzer cargo rangemap 1.7.1 range_wrapper/impl#[`RangeStartWrapper<T>`]new().(range);
270 let new_value = value;
271
272 // Is there a stored range either overlapping the start of
273 // the range to insert or immediately preceding it?
274 //
275 // If there is any such stored range, it will be the last
276 // whose start is less than or equal to the start of the range to insert,
277 // or the one before that if both of the above cases exist.
278 let mut candidates = self
279 .btmrust-analyzer cargo rangemap 1.7.1 map/RangeMap#btm.
280 .rangerust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/btree/map/impl#[`BTreeMap<K, V, A>`]range().::<RangeStartWrapperrust-analyzer cargo rangemap 1.7.1 range_wrapper/RangeStartWrapper#<K>, (Boundrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Bound#<&RangeStartWrapperrust-analyzer cargo rangemap 1.7.1 range_wrapper/RangeStartWrapper#<K>>, Boundrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Bound#<&RangeStartWrapperrust-analyzer cargo rangemap 1.7.1 range_wrapper/RangeStartWrapper#<K>>)>((
281 Boundrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Bound#::Unboundedrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Bound#Unbounded#,
282 Boundrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Bound#::Includedrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Bound#Included#(&new_start_wrapper),
283 ))
284 .revrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#rev().()
285 .takerust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#take().(2)
286 .filterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#filter().(|(stored_start_wrapper, _stored_value)| {
287 // Does the candidate range either overlap
288 // or immediately precede the range to insert?
289 // (Remember that it might actually cover the _whole_
290 // range to insert and then some.)
291 stored_start_wrapper
292 .end_wrapperrust-analyzer cargo rangemap 1.7.1 range_wrapper/RangeStartWrapper#end_wrapper.
293 .rangerust-analyzer cargo rangemap 1.7.1 range_wrapper/RangeEndWrapper#range.
294 .touchesrust-analyzer cargo rangemap 1.7.1 std_ext/impl#[`Range<T>`][`RangeExt<T>`]touches().(&new_start_wrapper.end_wrapperrust-analyzer cargo rangemap 1.7.1 range_wrapper/RangeStartWrapper#end_wrapper..rangerust-analyzer cargo rangemap 1.7.1 range_wrapper/RangeEndWrapper#range.)
295 });
296 if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(mut candidate) = candidates.nextrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/adapters/filter/impl#[`Filter<I, P>`][Iterator]next().() {
297 // Or the one before it if both cases described above exist.
298 if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(another_candidate) = candidates.nextrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/adapters/filter/impl#[`Filter<I, P>`][Iterator]next().() {
299 candidate = another_candidate;
300 }
301 let (stored_start_wrapper, stored_value) = (candidate.0.clonerust-analyzer cargo rangemap 1.7.1 range_wrapper/impl#[`RangeStartWrapper<T>`][Clone]clone().(), candidate.1.clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone#clone().());
302 self.adjust_touching_ranges_for_insertrust-analyzer cargo rangemap 1.7.1 map/impl#[`RangeMap<K, V>`]adjust_touching_ranges_for_insert().(
303 stored_start_wrapper,
304 stored_value,
305 &mut new_start_wrapper.end_wrapperrust-analyzer cargo rangemap 1.7.1 range_wrapper/RangeStartWrapper#end_wrapper..rangerust-analyzer cargo rangemap 1.7.1 range_wrapper/RangeEndWrapper#range.,
306 &new_value,
307 );
308 }
309
310 // Are there any stored ranges whose heads overlap or immediately
311 // follow the range to insert?
312 //
313 // If there are any such stored ranges (that weren't already caught above),
314 // their starts will fall somewhere after the start of the range to insert,
315 // and on or before its end.
316 //
317 // This time around, if the latter holds, it also implies
318 // the former so we don't need to check here if they touch.
319 //
320 // REVISIT: Possible micro-optimisation: `impl Borrow<T> for RangeStartWrapper<T>`
321 // and use that to search here, to avoid constructing another `RangeStartWrapper`.
322 let new_range_end_as_start = RangeStartWrapperrust-analyzer cargo rangemap 1.7.1 range_wrapper/RangeStartWrapper#::newrust-analyzer cargo rangemap 1.7.1 range_wrapper/impl#[`RangeStartWrapper<T>`]new().(
323 new_start_wrapper.end_wrapperrust-analyzer cargo rangemap 1.7.1 range_wrapper/RangeStartWrapper#end_wrapper..rangerust-analyzer cargo rangemap 1.7.1 range_wrapper/RangeEndWrapper#range..endrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#end..clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone#clone().()
324 ..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#new_start_wrapper.end_wrapperrust-analyzer cargo rangemap 1.7.1 range_wrapper/RangeStartWrapper#end_wrapper..rangerust-analyzer cargo rangemap 1.7.1 range_wrapper/RangeEndWrapper#range..endrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#end..clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone#clone().(),
325 );
326 while let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#((stored_start_wrapper, stored_value)) = self
327 .btmrust-analyzer cargo rangemap 1.7.1 map/RangeMap#btm.
328 .rangerust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/btree/map/impl#[`BTreeMap<K, V, A>`]range().::<RangeStartWrapperrust-analyzer cargo rangemap 1.7.1 range_wrapper/RangeStartWrapper#<K>, (Boundrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Bound#<&RangeStartWrapperrust-analyzer cargo rangemap 1.7.1 range_wrapper/RangeStartWrapper#<K>>, Boundrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Bound#<&RangeStartWrapperrust-analyzer cargo rangemap 1.7.1 range_wrapper/RangeStartWrapper#<K>>)>((
329 Boundrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Bound#::Includedrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Bound#Included#(&new_start_wrapper),
330 Boundrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Bound#::Includedrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Bound#Included#(&new_range_end_as_start),
331 ))
332 .nextrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/btree/map/impl#[`Range<'a, K, V>`][Iterator]next().()
333 {
334 // One extra exception: if we have different values,
335 // and the stored range starts at the end of the range to insert,
336 // then we don't want to keep looping forever trying to find more!
337 #[allow(clippy::suspicious_operation_groupings)]
338 if stored_start_wrapper.end_wrapperrust-analyzer cargo rangemap 1.7.1 range_wrapper/RangeStartWrapper#end_wrapper..rangerust-analyzer cargo rangemap 1.7.1 range_wrapper/RangeEndWrapper#range..startrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#start.
339 ==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq#eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq#eq().new_start_wrapper.end_wrapperrust-analyzer cargo rangemap 1.7.1 range_wrapper/RangeStartWrapper#end_wrapper..rangerust-analyzer cargo rangemap 1.7.1 range_wrapper/RangeEndWrapper#range..endrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#end.
340 && *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().stored_value 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().new_value
341 {
342 // We're beyond the last stored range that could be relevant.
343 // Avoid wasting time on irrelevant ranges, or even worse, looping forever.
344 // (`adjust_touching_ranges_for_insert` below assumes that the given range
345 // is relevant, and behaves very poorly if it is handed a range that it
346 // shouldn't be touching.)
347 break;
348 }
349
350 let stored_start_wrapper = stored_start_wrapper.clonerust-analyzer cargo rangemap 1.7.1 range_wrapper/impl#[`RangeStartWrapper<T>`][Clone]clone().();
351 let stored_value = stored_value.clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone#clone().();
352
353 self.adjust_touching_ranges_for_insertrust-analyzer cargo rangemap 1.7.1 map/impl#[`RangeMap<K, V>`]adjust_touching_ranges_for_insert().(
354 stored_start_wrapper,
355 stored_value,
356 &mut new_start_wrapper.end_wrapperrust-analyzer cargo rangemap 1.7.1 range_wrapper/RangeStartWrapper#end_wrapper..rangerust-analyzer cargo rangemap 1.7.1 range_wrapper/RangeEndWrapper#range.,
357 &new_value,
358 );
359 }
360
361 // Insert the (possibly expanded) new range, and we're done!
362 self.btmrust-analyzer cargo rangemap 1.7.1 map/RangeMap#btm..insertrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/btree/map/impl#[`BTreeMap<K, V, A>`]insert().(new_start_wrapper, new_value);
363 }
364
365 /// Removes a range from the map, if all or any of it was present.
366 ///
367 /// If the range to be removed _partially_ overlaps any ranges
368 /// in the map, then those ranges will be contracted to no
369 /// longer cover the removed range.
370 ///
371 ///
372 /// # Panics
373 ///
374 /// Panics if range `start >= end`.
375 pub fn removerust-analyzer cargo rangemap 1.7.1 map/impl#[`RangeMap<K, V>`]remove().(&mut self, range: Rangerust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#<K>) {
376 // We don't want to have to make empty ranges make sense;
377 // they don't represent anything meaningful in this structure.
378 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(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/PartialOrd#lt(). range.endrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#end.);
379
380 let start_wrapper: RangeStartWrapperrust-analyzer cargo rangemap 1.7.1 range_wrapper/RangeStartWrapper#<K> = RangeStartWrapperrust-analyzer cargo rangemap 1.7.1 range_wrapper/RangeStartWrapper#::newrust-analyzer cargo rangemap 1.7.1 range_wrapper/impl#[`RangeStartWrapper<T>`]new().(range);
381 let range = &start_wrapper.end_wrapperrust-analyzer cargo rangemap 1.7.1 range_wrapper/RangeStartWrapper#end_wrapper..rangerust-analyzer cargo rangemap 1.7.1 range_wrapper/RangeEndWrapper#range.;
382
383 // Is there a stored range overlapping the start of
384 // the range to insert?
385 //
386 // If there is any such stored range, it will be the last
387 // whose start is less than or equal to the start of the range to insert.
388 if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#((stored_start_wrapper, stored_value)) = self
389 .btmrust-analyzer cargo rangemap 1.7.1 map/RangeMap#btm.
390 .rangerust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/btree/map/impl#[`BTreeMap<K, V, A>`]range().::<RangeStartWrapperrust-analyzer cargo rangemap 1.7.1 range_wrapper/RangeStartWrapper#<K>, (Boundrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Bound#<&RangeStartWrapperrust-analyzer cargo rangemap 1.7.1 range_wrapper/RangeStartWrapper#<K>>, Boundrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Bound#<&RangeStartWrapperrust-analyzer cargo rangemap 1.7.1 range_wrapper/RangeStartWrapper#<K>>)>((Boundrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Bound#::Unboundedrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Bound#Unbounded#, Boundrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Bound#::Includedrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Bound#Included#(&start_wrapper)))
391 .next_backrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/btree/map/impl#[`Range<'a, K, V>`][DoubleEndedIterator]next_back().()
392 .filterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]filter().(|(stored_start_wrapper, _stored_value)| {
393 // Does the only candidate range overlap
394 // the range to insert?
395 stored_start_wrapper
396 .end_wrapperrust-analyzer cargo rangemap 1.7.1 range_wrapper/RangeStartWrapper#end_wrapper.
397 .rangerust-analyzer cargo rangemap 1.7.1 range_wrapper/RangeEndWrapper#range.
398 .overlapsrust-analyzer cargo rangemap 1.7.1 std_ext/impl#[`Range<T>`][`RangeExt<T>`]overlaps().(range)
399 })
400 .maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]map().(|(stored_start_wrapper, stored_value)| {
401 (stored_start_wrapper.clonerust-analyzer cargo rangemap 1.7.1 range_wrapper/impl#[`RangeStartWrapper<T>`][Clone]clone().(), stored_value.clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone#clone().())
402 })
403 {
404 self.adjust_overlapping_ranges_for_removerust-analyzer cargo rangemap 1.7.1 map/impl#[`RangeMap<K, V>`]adjust_overlapping_ranges_for_remove().(
405 stored_start_wrapper,
406 stored_value,
407 range,
408 );
409 }
410
411 // Are there any stored ranges whose heads overlap the range to insert?
412 //
413 // If there are any such stored ranges (that weren't already caught above),
414 // their starts will fall somewhere after the start of the range to insert,
415 // and before its end.
416 //
417 // REVISIT: Possible micro-optimisation: `impl Borrow<T> for RangeStartWrapper<T>`
418 // and use that to search here, to avoid constructing another `RangeStartWrapper`.
419 let new_range_end_as_start = RangeStartWrapperrust-analyzer cargo rangemap 1.7.1 range_wrapper/RangeStartWrapper#::newrust-analyzer cargo rangemap 1.7.1 range_wrapper/impl#[`RangeStartWrapper<T>`]new().(range.endrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#end..clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone#clone().()..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#range.endrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#end..clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone#clone().());
420 while let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#((stored_start_wrapper, stored_value)) = self
421 .btmrust-analyzer cargo rangemap 1.7.1 map/RangeMap#btm.
422 .rangerust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/btree/map/impl#[`BTreeMap<K, V, A>`]range().::<RangeStartWrapperrust-analyzer cargo rangemap 1.7.1 range_wrapper/RangeStartWrapper#<K>, (Boundrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Bound#<&RangeStartWrapperrust-analyzer cargo rangemap 1.7.1 range_wrapper/RangeStartWrapper#<K>>, Boundrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Bound#<&RangeStartWrapperrust-analyzer cargo rangemap 1.7.1 range_wrapper/RangeStartWrapper#<K>>)>((
423 Boundrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Bound#::Excludedrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Bound#Excluded#(&start_wrapper),
424 Boundrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Bound#::Excludedrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Bound#Excluded#(&new_range_end_as_start),
425 ))
426 .nextrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/btree/map/impl#[`Range<'a, K, V>`][Iterator]next().()
427 .maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]map().(|(stored_start_wrapper, stored_value)| {
428 (stored_start_wrapper.clonerust-analyzer cargo rangemap 1.7.1 range_wrapper/impl#[`RangeStartWrapper<T>`][Clone]clone().(), stored_value.clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone#clone().())
429 })
430 {
431 self.adjust_overlapping_ranges_for_removerust-analyzer cargo rangemap 1.7.1 map/impl#[`RangeMap<K, V>`]adjust_overlapping_ranges_for_remove().(
432 stored_start_wrapper,
433 stored_value,
434 range,
435 );
436 }
437 }
438
439 fn adjust_touching_ranges_for_insertrust-analyzer cargo rangemap 1.7.1 map/impl#[`RangeMap<K, V>`]adjust_touching_ranges_for_insert().(
440 &mut self,
441 stored_start_wrapper: RangeStartWrapperrust-analyzer cargo rangemap 1.7.1 range_wrapper/RangeStartWrapper#<K>,
442 stored_value: V,
443 new_range: &mut Rangerust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#<K>,
444 new_value: &V,
445 ) {
446 use corerust-analyzer cargo core https://github.com/rust-lang/rust/library/core crate/::cmprust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/::{maxrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/max()., minrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/min().};
447
448 if stored_value rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq#eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq#eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq#eq().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().new_value {
449 // The ranges have the same value, so we can "adopt"
450 // the stored range.
451 //
452 // This means that no matter how big or where the stored range is,
453 // we will expand the new range's bounds to subsume it,
454 // and then delete the stored range.
455 new_range.startrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#start. = minrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/min().(&new_range.startrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#start., &stored_start_wrapper.startrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#start.).clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone#clone().();
456 new_range.endrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#end. = maxrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/max().(&new_range.endrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#end., &stored_start_wrapper.endrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#end.).clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone#clone().();
457 self.btmrust-analyzer cargo rangemap 1.7.1 map/RangeMap#btm..removerust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/btree/map/impl#[`BTreeMap<K, V, A>`]remove().(&stored_start_wrapper);
458 } else {
459 // The ranges have different values.
460 if new_range.overlapsrust-analyzer cargo rangemap 1.7.1 std_ext/impl#[`Range<T>`][`RangeExt<T>`]overlaps().(&stored_start_wrapper.rangerust-analyzer cargo rangemap 1.7.1 range_wrapper/RangeEndWrapper#range.) {
461 // The ranges overlap. This is a little bit more complicated.
462 // Delete the stored range, and then add back between
463 // 0 and 2 subranges at the ends of the range to insert.
464 self.btmrust-analyzer cargo rangemap 1.7.1 map/RangeMap#btm..removerust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/btree/map/impl#[`BTreeMap<K, V, A>`]remove().(&stored_start_wrapper);
465 if stored_start_wrapper.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/PartialOrd#lt().<rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialOrd#lt(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialOrd#lt().new_range.startrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#start. {
466 // Insert the piece left of the range to insert.
467 self.btmrust-analyzer cargo rangemap 1.7.1 map/RangeMap#btm..insertrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/btree/map/impl#[`BTreeMap<K, V, A>`]insert().(
468 RangeStartWrapperrust-analyzer cargo rangemap 1.7.1 range_wrapper/RangeStartWrapper#::newrust-analyzer cargo rangemap 1.7.1 range_wrapper/impl#[`RangeStartWrapper<T>`]new().(
469 stored_start_wrapper.end_wrapperrust-analyzer cargo rangemap 1.7.1 range_wrapper/RangeStartWrapper#end_wrapper..rangerust-analyzer cargo rangemap 1.7.1 range_wrapper/RangeEndWrapper#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 ops/range/Range#new_range.startrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#start..clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone#clone().(),
470 ),
471 stored_value.clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone#clone().(),
472 );
473 }
474 if stored_start_wrapper.end_wrapperrust-analyzer cargo rangemap 1.7.1 range_wrapper/RangeStartWrapper#end_wrapper..rangerust-analyzer cargo rangemap 1.7.1 range_wrapper/RangeEndWrapper#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 cmp/PartialOrd#gt().>rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialOrd#gt(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialOrd#gt().new_range.endrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#end. {
475 // Insert the piece right of the range to insert.
476 self.btmrust-analyzer cargo rangemap 1.7.1 map/RangeMap#btm..insertrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/btree/map/impl#[`BTreeMap<K, V, A>`]insert().(
477 RangeStartWrapperrust-analyzer cargo rangemap 1.7.1 range_wrapper/RangeStartWrapper#::newrust-analyzer cargo rangemap 1.7.1 range_wrapper/impl#[`RangeStartWrapper<T>`]new().(
478 new_range.endrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#end..clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone#clone().()..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#stored_start_wrapper.end_wrapperrust-analyzer cargo rangemap 1.7.1 range_wrapper/RangeStartWrapper#end_wrapper..rangerust-analyzer cargo rangemap 1.7.1 range_wrapper/RangeEndWrapper#range..endrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#end.,
479 ),
480 stored_value,
481 );
482 }
483 } else {
484 // No-op; they're not overlapping,
485 // so we can just keep both ranges as they are.
486 }
487 }
488 }
489
490 fn adjust_overlapping_ranges_for_removerust-analyzer cargo rangemap 1.7.1 map/impl#[`RangeMap<K, V>`]adjust_overlapping_ranges_for_remove().(
491 &mut self,
492 stored: RangeStartWrapperrust-analyzer cargo rangemap 1.7.1 range_wrapper/RangeStartWrapper#<K>,
493 stored_value: V,
494 range_to_remove: &Rangerust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#<K>,
495 ) {
496 // Delete the stored range, and then add back between
497 // 0 and 2 subranges at the ends of the range to insert.
498 self.btmrust-analyzer cargo rangemap 1.7.1 map/RangeMap#btm..removerust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/btree/map/impl#[`BTreeMap<K, V, A>`]remove().(&stored);
499 let stored_range = stored.end_wrapperrust-analyzer cargo rangemap 1.7.1 range_wrapper/RangeStartWrapper#end_wrapper.;
500 if stored_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/PartialOrd#lt().<rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialOrd#lt(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialOrd#lt().range_to_remove.startrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#start. {
501 // Insert the piece left of the range to insert.
502 self.btmrust-analyzer cargo rangemap 1.7.1 map/RangeMap#btm..insertrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/btree/map/impl#[`BTreeMap<K, V, A>`]insert().(
503 RangeStartWrapperrust-analyzer cargo rangemap 1.7.1 range_wrapper/RangeStartWrapper#::newrust-analyzer cargo rangemap 1.7.1 range_wrapper/impl#[`RangeStartWrapper<T>`]new().(stored_range.rangerust-analyzer cargo rangemap 1.7.1 range_wrapper/RangeEndWrapper#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 ops/range/Range#range_to_remove.startrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#start..clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone#clone().()),
504 stored_value.clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone#clone().(),
505 );
506 }
507 if stored_range.rangerust-analyzer cargo rangemap 1.7.1 range_wrapper/RangeEndWrapper#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 cmp/PartialOrd#gt().>rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialOrd#gt(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialOrd#gt().range_to_remove.endrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#end. {
508 // Insert the piece right of the range to insert.
509 self.btmrust-analyzer cargo rangemap 1.7.1 map/RangeMap#btm..insertrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/btree/map/impl#[`BTreeMap<K, V, A>`]insert().(
510 RangeStartWrapperrust-analyzer cargo rangemap 1.7.1 range_wrapper/RangeStartWrapper#::newrust-analyzer cargo rangemap 1.7.1 range_wrapper/impl#[`RangeStartWrapper<T>`]new().(range_to_remove.endrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#end..clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone#clone().()..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#stored_range.rangerust-analyzer cargo rangemap 1.7.1 range_wrapper/RangeEndWrapper#range..endrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#end.),
511 stored_value,
512 );
513 }
514 }
515 }
516
517 /// An iterator over the entries of a `RangeMap`, ordered by key range.
518 ///
519 /// The iterator element type is `(&'a Range<K>, &'a V)`.
520 ///
521 /// This `struct` is created by the [`iter`] method on [`RangeMap`]. See its
522 /// documentation for more.
523 ///
524 /// [`iter`]: RangeMap::iter
525 pub struct Iterrust-analyzer cargo rangemap 1.7.1 map/Iter#<'a, K, V> {
526 innerrust-analyzer cargo rangemap 1.7.1 map/Iter#inner.: allocrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc crate/::collectionsrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/::btree_maprust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/btree_map/::Iterrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/btree/map/Iter#<'a, RangeStartWrapperrust-analyzer cargo rangemap 1.7.1 range_wrapper/RangeStartWrapper#<K>, V>,
527 }
528
529 impl<'a, K, V> Iteratorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator# for Iterrust-analyzer cargo rangemap 1.7.1 map/Iter#<'a, K, V>
530 where
531 K: 'a,
532 V: 'a,
533 {
534 type Itemrust-analyzer cargo rangemap 1.7.1 map/impl#[`Iter<'a, K, V>`][Iterator]Item# = (&'a Rangerust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#<K>, &'a V);
535
536 fn nextrust-analyzer cargo rangemap 1.7.1 map/impl#[`Iter<'a, K, V>`][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 map/impl#[`Iter<'a, K, V>`][Iterator]::Itemrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#Item#> {
537 self.innerrust-analyzer cargo rangemap 1.7.1 map/Iter#inner.
538 .nextrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/btree/map/impl#[`Iter<'a, K, V>`][Iterator]next().()
539 .maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]map().(|(by_start, v)| (&by_start.end_wrapperrust-analyzer cargo rangemap 1.7.1 range_wrapper/RangeStartWrapper#end_wrapper..rangerust-analyzer cargo rangemap 1.7.1 range_wrapper/RangeEndWrapper#range., v))
540 }
541
542 fn size_hintrust-analyzer cargo rangemap 1.7.1 map/impl#[`Iter<'a, K, V>`][Iterator]size_hint().(&self) -> (usize, Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<usize>) {
543 self.innerrust-analyzer cargo rangemap 1.7.1 map/Iter#inner..size_hintrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/btree/map/impl#[`Iter<'a, K, V>`][Iterator]size_hint().()
544 }
545 }
546
547 impl<'a, K, V> 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 map/Iter#<'a, K, V>
548 where
549 K: 'a,
550 V: 'a,
551 {
552 fn next_backrust-analyzer cargo rangemap 1.7.1 map/impl#[`Iter<'a, K, V>`][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 map/impl#[`Iter<'a, K, V>`][DoubleEndedIterator]::Itemrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#Item#> {
553 self.innerrust-analyzer cargo rangemap 1.7.1 map/Iter#inner.
554 .next_backrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/btree/map/impl#[`Iter<'a, K, V>`][DoubleEndedIterator]next_back().()
555 .maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]map().(|(range, value)| (&range.end_wrapperrust-analyzer cargo rangemap 1.7.1 range_wrapper/RangeStartWrapper#end_wrapper..rangerust-analyzer cargo rangemap 1.7.1 range_wrapper/RangeEndWrapper#range., value))
556 }
557 }
558
559 /// An owning iterator over the entries of a `RangeMap`, ordered by key range.
560 ///
561 /// The iterator element type is `(Range<K>, V)`.
562 ///
563 /// This `struct` is created by the [`into_iter`] method on [`RangeMap`]
564 /// (provided by the `IntoIterator` trait). See its documentation for more.
565 ///
566 /// [`into_iter`]: IntoIterator::into_iter
567 pub struct IntoIterrust-analyzer cargo rangemap 1.7.1 map/IntoIter#<K, V> {
568 innerrust-analyzer cargo rangemap 1.7.1 map/IntoIter#inner.: allocrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc crate/::collectionsrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/::btree_maprust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/btree_map/::IntoIterrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/btree/map/IntoIter#<RangeStartWrapperrust-analyzer cargo rangemap 1.7.1 range_wrapper/RangeStartWrapper#<K>, V>,
569 }
570
571 impl<K, V> IntoIteratorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/collect/IntoIterator# for RangeMaprust-analyzer cargo rangemap 1.7.1 map/RangeMap#<K, V> {
572 type Itemrust-analyzer cargo rangemap 1.7.1 map/impl#[`RangeMap<K, V>`][IntoIterator]Item# = (Rangerust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#<K>, V);
573 type IntoIterrust-analyzer cargo rangemap 1.7.1 map/impl#[`RangeMap<K, V>`][IntoIterator]IntoIter# = IntoIterrust-analyzer cargo rangemap 1.7.1 map/IntoIter#<K, V>;
574 fn into_iterrust-analyzer cargo rangemap 1.7.1 map/impl#[`RangeMap<K, V>`][IntoIterator]into_iter().(self) -> Selfrust-analyzer cargo rangemap 1.7.1 map/impl#[`RangeMap<K, V>`][IntoIterator]::IntoIterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/collect/IntoIterator#IntoIter# {
575 IntoIterrust-analyzer cargo rangemap 1.7.1 map/IntoIter# {
576 innerrust-analyzer cargo rangemap 1.7.1 map/IntoIter#inner.: self.btmrust-analyzer cargo rangemap 1.7.1 map/RangeMap#btm..into_iterrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/btree/map/impl#[`BTreeMap<K, V, A>`][IntoIterator]into_iter().(),
577 }
578 }
579 }
580
581 impl<K, V> Iteratorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator# for IntoIterrust-analyzer cargo rangemap 1.7.1 map/IntoIter#<K, V> {
582 type Itemrust-analyzer cargo rangemap 1.7.1 map/impl#[`IntoIter<K, V>`][Iterator]Item# = (Rangerust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#<K>, V);
583 fn nextrust-analyzer cargo rangemap 1.7.1 map/impl#[`IntoIter<K, V>`][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#<K>, V)> {
584 self.innerrust-analyzer cargo rangemap 1.7.1 map/IntoIter#inner.
585 .nextrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/btree/map/impl#[`IntoIter<K, V, A>`][Iterator]next().()
586 .maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]map().(|(by_start, v)| (by_start.end_wrapperrust-analyzer cargo rangemap 1.7.1 range_wrapper/RangeStartWrapper#end_wrapper..rangerust-analyzer cargo rangemap 1.7.1 range_wrapper/RangeEndWrapper#range., v))
587 }
588 fn size_hintrust-analyzer cargo rangemap 1.7.1 map/impl#[`IntoIter<K, V>`][Iterator]size_hint().(&self) -> (usize, Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<usize>) {
589 self.innerrust-analyzer cargo rangemap 1.7.1 map/IntoIter#inner..size_hintrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/btree/map/impl#[`IntoIter<K, V, A>`][Iterator]size_hint().()
590 }
591 }
592
593 impl<K, V> 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 map/IntoIter#<K, V> {
594 fn next_backrust-analyzer cargo rangemap 1.7.1 map/impl#[`IntoIter<K, V>`][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 map/impl#[`IntoIter<K, V>`][DoubleEndedIterator]::Itemrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#Item#> {
595 self.innerrust-analyzer cargo rangemap 1.7.1 map/IntoIter#inner.
596 .next_backrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/btree/map/impl#[`IntoIter<K, V, A>`][DoubleEndedIterator]next_back().()
597 .maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]map().(|(range, value)| (range.end_wrapperrust-analyzer cargo rangemap 1.7.1 range_wrapper/RangeStartWrapper#end_wrapper..rangerust-analyzer cargo rangemap 1.7.1 range_wrapper/RangeEndWrapper#range., value))
598 }
599 }
600
601 // We can't just derive this automatically, because that would
602 // expose irrelevant (and private) implementation details.
603 // Instead implement it in the same way that the underlying BTreeMap does.
604 impl<K: Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Debug#, V: 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 RangeMaprust-analyzer cargo rangemap 1.7.1 map/RangeMap#<K, V> {
605 fn fmtrust-analyzer cargo rangemap 1.7.1 map/impl#[`RangeMap<K, V>`][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# {
606 f.debug_maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/impl#[`Formatter<'a>`]debug_map().().entriesrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/builders/impl#[`DebugMap<'a, 'b>`]entries().(self.iterrust-analyzer cargo rangemap 1.7.1 map/impl#[`RangeMap<K, V>`]iter().()).finishrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/builders/impl#[`DebugMap<'a, 'b>`]finish().()
607 }
608 }
609
610 impl<K, V> 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#<K>, V)> for RangeMaprust-analyzer cargo rangemap 1.7.1 map/RangeMap#<K, V>
611 where
612 K: 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#,
613 V: PartialEqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq# + Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone#,
614 {
615 fn from_iterrust-analyzer cargo rangemap 1.7.1 map/impl#[`RangeMap<K, V>`][`FromIterator<(Range<K>, V)>`]from_iter().<T: 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#<K>, V)>>(iter: T) -> Selfrust-analyzer cargo rangemap 1.7.1 map/impl#[`RangeMap<K, V>`][`FromIterator<(Range<K>, V)>`] {
616 let mut range_map = RangeMaprust-analyzer cargo rangemap 1.7.1 map/RangeMap#::newrust-analyzer cargo rangemap 1.7.1 map/impl#[`RangeMap<K, V>`]new().();
617 range_map.extendrust-analyzer cargo rangemap 1.7.1 map/impl#[`RangeMap<K, V>`][`Extend<(Range<K>, V)>`]extend().(iter);
618 range_map
619 }
620 }
621
622 impl<K, V> 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#<K>, V)> for RangeMaprust-analyzer cargo rangemap 1.7.1 map/RangeMap#<K, V>
623 where
624 K: 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#,
625 V: PartialEqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq# + Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone#,
626 {
627 fn extendrust-analyzer cargo rangemap 1.7.1 map/impl#[`RangeMap<K, V>`][`Extend<(Range<K>, V)>`]extend().<T: 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#<K>, V)>>(&mut self, iter: T) {
628 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 |(k, v)| {
629 self.insertrust-analyzer cargo rangemap 1.7.1 map/impl#[`RangeMap<K, V>`]insert().(k, v);
630 })
631 }
632 }
633
634 #[cfg(feature = "serde1")]
635 impl<K, V> Serializerust-analyzer cargo serde 1.0.219 ser/Serialize# for RangeMaprust-analyzer cargo rangemap 1.7.1 map/RangeMap#<K, V>
636 where
637 K: Serializerust-analyzer cargo serde 1.0.219 ser/Serialize#,
638 V: Serializerust-analyzer cargo serde 1.0.219 ser/Serialize#,
639 {
640 fn serializerust-analyzer cargo rangemap 1.7.1 map/impl#[`RangeMap<K, V>`][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#>
641 where
642 S: Serializerrust-analyzer cargo serde 1.0.219 ser/Serializer#,
643 {
644 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#;
645 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.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().;
646 for (k, v) in self.iterrust-analyzer cargo rangemap 1.7.1 map/impl#[`RangeMap<K, V>`]iter().() {
647 seq.serialize_elementrust-analyzer cargo serde 1.0.219 ser/SerializeSeq#serialize_element().(&((&k.startrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#start., &k.endrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#end.), &v))?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
648 }
649 seq.endrust-analyzer cargo serde 1.0.219 ser/SerializeSeq#end().()
650 }
651 }
652
653 #[cfg(feature = "serde1")]
654 impl<'de, K, V> Deserializerust-analyzer cargo serde 1.0.219 de/Deserialize#<'de> for RangeMaprust-analyzer cargo rangemap 1.7.1 map/RangeMap#<K, V>
655 where
656 K: 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>,
657 V: PartialEqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq# + Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone# + Deserializerust-analyzer cargo serde 1.0.219 de/Deserialize#<'de>,
658 {
659 fn deserializerust-analyzer cargo rangemap 1.7.1 map/impl#[`RangeMap<K, V>`][`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 map/impl#[`RangeMap<K, V>`][`Deserialize<'de>`], D::Errorrust-analyzer cargo serde 1.0.219 de/Deserializer#Error#>
660 where
661 D: Deserializerrust-analyzer cargo serde 1.0.219 de/Deserializer#<'de>,
662 {
663 deserializer.deserialize_seqrust-analyzer cargo serde 1.0.219 de/Deserializer#deserialize_seq().(RangeMapVisitorrust-analyzer cargo rangemap 1.7.1 map/RangeMapVisitor#::newrust-analyzer cargo rangemap 1.7.1 map/impl#[`RangeMapVisitor<K, V>`]new().())
664 }
665 }
666
667 #[cfg(feature = "serde1")]
668 struct RangeMapVisitorrust-analyzer cargo rangemap 1.7.1 map/RangeMapVisitor#<K, V> {
669 markerrust-analyzer cargo rangemap 1.7.1 map/RangeMapVisitor#marker.: PhantomDatarust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/PhantomData#<fn() -> RangeMaprust-analyzer cargo rangemap 1.7.1 map/RangeMap#<K, V>>,
670 }
671
672 #[cfg(feature = "serde1")]
673 impl<K, V> RangeMapVisitorrust-analyzer cargo rangemap 1.7.1 map/RangeMapVisitor#<K, V> {
674 fn newrust-analyzer cargo rangemap 1.7.1 map/impl#[`RangeMapVisitor<K, V>`]new().() -> Selfrust-analyzer cargo rangemap 1.7.1 map/impl#[`RangeMapVisitor<K, V>`] {
675 RangeMapVisitorrust-analyzer cargo rangemap 1.7.1 map/RangeMapVisitor# {
676 markerrust-analyzer cargo rangemap 1.7.1 map/RangeMapVisitor#marker.: PhantomDatarust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/PhantomData#,
677 }
678 }
679 }
680
681 #[cfg(feature = "serde1")]
682 impl<'de, K, V> Visitorrust-analyzer cargo serde 1.0.219 de/Visitor#<'de> for RangeMapVisitorrust-analyzer cargo rangemap 1.7.1 map/RangeMapVisitor#<K, V>
683 where
684 K: 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>,
685 V: PartialEqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq# + Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone# + Deserializerust-analyzer cargo serde 1.0.219 de/Deserialize#<'de>,
686 {
687 type Valuerust-analyzer cargo rangemap 1.7.1 map/impl#[`RangeMapVisitor<K, V>`][`Visitor<'de>`]Value# = RangeMaprust-analyzer cargo rangemap 1.7.1 map/RangeMap#<K, V>;
688
689 fn expectingrust-analyzer cargo rangemap 1.7.1 map/impl#[`RangeMapVisitor<K, V>`][`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# {
690 formatter.write_strrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/impl#[`Formatter<'a>`]write_str().("RangeMap")
691 }
692
693 fn visit_seqrust-analyzer cargo rangemap 1.7.1 map/impl#[`RangeMapVisitor<K, V>`][`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 map/impl#[`RangeMapVisitor<K, V>`][`Visitor<'de>`]::Valuerust-analyzer cargo serde 1.0.219 de/Visitor#Value#, A::Errorrust-analyzer cargo serde 1.0.219 de/SeqAccess#Error#>
694 where
695 A: SeqAccessrust-analyzer cargo serde 1.0.219 de/SeqAccess#<'de>,
696 {
697 let mut range_map = RangeMaprust-analyzer cargo rangemap 1.7.1 map/RangeMap#::newrust-analyzer cargo rangemap 1.7.1 map/impl#[`RangeMap<K, V>`]new().();
698 while let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(((start, end), value)) = 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(). {
699 range_map.insertrust-analyzer cargo rangemap 1.7.1 map/impl#[`RangeMap<K, V>`]insert().(start..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#end, value);
700 }
701 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(range_map)
702 }
703 }
704
705 /// An iterator over all ranges not covered by a `RangeMap`.
706 ///
707 /// The iterator element type is `Range<K>`.
708 ///
709 /// This `struct` is created by the [`gaps`] method on [`RangeMap`]. See its
710 /// documentation for more.
711 ///
712 /// [`gaps`]: RangeMap::gaps
713 pub struct Gapsrust-analyzer cargo rangemap 1.7.1 map/Gaps#<'a, K, V> {
714 candidate_startrust-analyzer cargo rangemap 1.7.1 map/Gaps#candidate_start.: &'a K,
715 query_endrust-analyzer cargo rangemap 1.7.1 map/Gaps#query_end.: &'a K,
716 btm_range_iterrust-analyzer cargo rangemap 1.7.1 map/Gaps#btm_range_iter.: allocrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc crate/::collectionsrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/::btree_maprust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/btree_map/::Rangerust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/btree/map/Range#<'a, RangeStartWrapperrust-analyzer cargo rangemap 1.7.1 range_wrapper/RangeStartWrapper#<K>, V>,
717 }
718
719 // `Gaps` is always fused. (See definition of `next` below.)
720 impl<'a, K, V> 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 map/Gaps#<'a, K, V> where K: 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# {}
721
722 impl<'a, K, V> Iteratorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator# for Gapsrust-analyzer cargo rangemap 1.7.1 map/Gaps#<'a, K, V>
723 where
724 K: 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#,
725 {
726 type Itemrust-analyzer cargo rangemap 1.7.1 map/impl#[`Gaps<'a, K, V>`][Iterator]Item# = Rangerust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#<K>;
727
728 fn nextrust-analyzer cargo rangemap 1.7.1 map/impl#[`Gaps<'a, K, V>`][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 map/impl#[`Gaps<'a, K, V>`][Iterator]::Itemrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#Item#> {
729 // Keep track of the next range in the map beyond the current returned range.
730 for overlap in self.btm_range_iterrust-analyzer cargo rangemap 1.7.1 map/Gaps#btm_range_iter..by_refrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#by_ref().() {
731 let overlap = &overlap.0.rangerust-analyzer cargo rangemap 1.7.1 range_wrapper/RangeEndWrapper#range.;
732
733 // If the range in the map has advanced beyond the query range, return
734 // any tail gap.
735 if *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().self.query_endrust-analyzer cargo rangemap 1.7.1 map/Gaps#query_end. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialOrd#le().<=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialOrd#le(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialOrd#le().overlap.startrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#start. {
736 break;
737 }
738
739 let original_start = corerust-analyzer cargo core https://github.com/rust-lang/rust/library/core crate/::memrust-analyzer cargo core https://github.com/rust-lang/rust/library/core mem/::replacerust-analyzer cargo core https://github.com/rust-lang/rust/library/core mem/replace().(&mut self.candidate_startrust-analyzer cargo rangemap 1.7.1 map/Gaps#candidate_start., &overlap.endrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#end.);
740
741 // The query range overhangs to the left, return a gap.
742 if *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().original_start rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialOrd#lt().<rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialOrd#lt(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialOrd#lt().overlap.startrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#start. {
743 let gap = original_start.clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone#clone().()..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#overlap.startrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#start..clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone#clone().();
744 return Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(gap);
745 }
746
747 // The remaining query range starts within the current
748 // mapped range.
749 self.candidate_startrust-analyzer cargo rangemap 1.7.1 map/Gaps#candidate_start. = &overlap.endrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#end.;
750 }
751
752 // Now that we've run out of items, the only other possible
753 // gap is at the end of the query range.
754 if *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().self.candidate_startrust-analyzer cargo rangemap 1.7.1 map/Gaps#candidate_start. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialOrd#lt().<rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialOrd#lt(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialOrd#lt().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().self.query_endrust-analyzer cargo rangemap 1.7.1 map/Gaps#query_end. {
755 let gap = self.candidate_startrust-analyzer cargo rangemap 1.7.1 map/Gaps#candidate_start..clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone#clone().()..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#self.query_endrust-analyzer cargo rangemap 1.7.1 map/Gaps#query_end..clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone#clone().();
756 self.candidate_startrust-analyzer cargo rangemap 1.7.1 map/Gaps#candidate_start. = self.query_endrust-analyzer cargo rangemap 1.7.1 map/Gaps#query_end.;
757 return Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(gap);
758 }
759
760 Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#
761 }
762 }
763
764 /// An iterator over all stored ranges partially or completely
765 /// overlapped by a given range.
766 ///
767 /// The iterator element type is `(&'a Range<K>, &'a V)`.
768 ///
769 /// This `struct` is created by the [`overlapping`] method on [`RangeMap`]. See its
770 /// documentation for more.
771 ///
772 /// [`overlapping`]: RangeMap::overlapping
773 pub struct Overlappingrust-analyzer cargo rangemap 1.7.1 map/Overlapping#<'a, K, V, 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#<K>> = &'a Rangerust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#<K>> {
774 query_rangerust-analyzer cargo rangemap 1.7.1 map/Overlapping#query_range.: R,
775 btm_range_iterrust-analyzer cargo rangemap 1.7.1 map/Overlapping#btm_range_iter.: allocrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc crate/::collectionsrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/::btree_maprust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/btree_map/::Rangerust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/btree/map/Range#<'a, RangeStartWrapperrust-analyzer cargo rangemap 1.7.1 range_wrapper/RangeStartWrapper#<K>, V>,
776 }
777
778 // `Overlapping` is always fused. (See definition of `next` below.)
779 impl<'a, K, V, 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#<K>>> 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 map/Overlapping#<'a, K, V, R> where
780 K: Ordrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Ord#
781 {
782 }
783
784 impl<'a, K, V, 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#<K>>> Iteratorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator# for Overlappingrust-analyzer cargo rangemap 1.7.1 map/Overlapping#<'a, K, V, R>
785 where
786 K: Ordrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Ord#,
787 {
788 type Itemrust-analyzer cargo rangemap 1.7.1 map/impl#[`Overlapping<'a, K, V, R>`][Iterator]Item# = (&'a Rangerust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#<K>, &'a V);
789
790 fn nextrust-analyzer cargo rangemap 1.7.1 map/impl#[`Overlapping<'a, K, V, 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 map/impl#[`Overlapping<'a, K, V, R>`][Iterator]::Itemrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#Item#> {
791 if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#((k, v)) = self.btm_range_iterrust-analyzer cargo rangemap 1.7.1 map/Overlapping#btm_range_iter..nextrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/btree/map/impl#[`Range<'a, K, V>`][Iterator]next().() {
792 if k.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/PartialOrd#lt().<rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialOrd#lt(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialOrd#lt().self.query_rangerust-analyzer cargo rangemap 1.7.1 map/Overlapping#query_range..borrowrust-analyzer cargo core https://github.com/rust-lang/rust/library/core borrow/Borrow#borrow().().endrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#end. {
793 Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#((&k.rangerust-analyzer cargo rangemap 1.7.1 range_wrapper/RangeEndWrapper#range., v))
794 } else {
795 // The rest of the items in the underlying iterator
796 // are past the query range. We can keep taking items
797 // from that iterator and this will remain true,
798 // so this is enough to make the iterator fused.
799 Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#
800 }
801 } else {
802 Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#
803 }
804 }
805 }
806
807 impl<'a, K, V, 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#<K>>> 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 map/Overlapping#<'a, K, V, R>
808 where
809 K: Ordrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Ord#,
810 {
811 fn next_backrust-analyzer cargo rangemap 1.7.1 map/impl#[`Overlapping<'a, K, V, 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 map/impl#[`Overlapping<'a, K, V, R>`][DoubleEndedIterator]::Itemrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#Item#> {
812 while let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#((k, v)) = self.btm_range_iterrust-analyzer cargo rangemap 1.7.1 map/Overlapping#btm_range_iter..next_backrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/btree/map/impl#[`Range<'a, K, V>`][DoubleEndedIterator]next_back().() {
813 if k.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/PartialOrd#lt().<rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialOrd#lt(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialOrd#lt().self.query_rangerust-analyzer cargo rangemap 1.7.1 map/Overlapping#query_range..borrowrust-analyzer cargo core https://github.com/rust-lang/rust/library/core borrow/Borrow#borrow().().endrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#end. {
814 return Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#((&k.rangerust-analyzer cargo rangemap 1.7.1 range_wrapper/RangeEndWrapper#range., v));
815 }
816 }
817
818 Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#
819 }
820 }
821
822 impl<K: 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#, V: PartialEqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq# + 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#<K>, V); N]> for RangeMaprust-analyzer cargo rangemap 1.7.1 map/RangeMap#<K, V> {
823 fn fromrust-analyzer cargo rangemap 1.7.1 map/impl#[`RangeMap<K, V>`][`From<[(Range<K>, V); N]>`]from().(value: [(Rangerust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#<K>, V); N]) -> Selfrust-analyzer cargo rangemap 1.7.1 map/impl#[`RangeMap<K, V>`][`From<[(Range<K>, V); N]>`] {
824 let mut map = Selfrust-analyzer cargo rangemap 1.7.1 map/impl#[`RangeMap<K, V>`][`From<[(Range<K>, V); N]>`]::newrust-analyzer cargo rangemap 1.7.1 map/impl#[`RangeMap<K, V>`]new().();
825 for (range, 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) {
826 map.insertrust-analyzer cargo rangemap 1.7.1 map/impl#[`RangeMap<K, V>`]insert().(range, value);
827 }
828 map
829 }
830 }
831
832 /// Create a [`RangeMap`] from key-value pairs.
833 ///
834 /// # Example
835 ///
836 /// ```rust
837 /// # use rangemap::range_map;
838 /// let map = range_map!{
839 /// 0..100 => "abc",
840 /// 100..200 => "def",
841 /// 200..300 => "ghi"
842 /// };
843 /// ```
844 #[macro_export]
845 macro_rules! range_maprust-analyzer cargo rangemap 1.7.1 map/range_map! {
846 ($($k:expr => $v:expr),* $(,)?) => {{
847 $crate::RangeMap::from([$(($k, $v)),*])
848 }};
849 }
850
851 #[cfg(test)]
852 mod testsrust-analyzer cargo rangemap 1.7.1 map/tests/ {
853 use superrust-analyzer cargo rangemap 1.7.1 map/::*;
854 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/;
855 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!, stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/::Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#, 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#};
•856 //use proptest::prelude::*;
857 //use test_strategy::proptest;
858
•859 /*impl<K, V> Arbitrary for RangeMap<K, V>
860 where
861 K: Ord + Clone + Debug + Arbitrary + 'static,
862 V: Clone + PartialEq + Arbitrary + 'static,
863 {
864 type Parameters = ();
865 type Strategy = BoxedStrategy<Self>;
866
867 fn arbitrary_with(_parameters: Self::Parameters) -> Self::Strategy {
868 any::<Vec<(Range<K>, V)>>()
869 .prop_map(|ranges| ranges.into_iter().collect::<RangeMap<K, V>>())
870 .boxed()
871 }
872 }
873
874 #[proptest]
875 fn test_first(set: RangeMap<u64, String>) {
876 assert_eq!(
877 set.first_range_value(),
878 set.iter().min_by_key(|(range, _)| range.start)
879 );
880 }
881
882 #[proptest]
883 #[allow(clippy::len_zero)]
884 fn test_len(mut map: RangeMap<u64, String>) {
885 assert_eq!(map.len(), map.iter().count());
886 assert_eq!(map.is_empty(), map.len() == 0);
887 map.clear();
888 assert_eq!(map.len(), 0);
889 assert!(map.is_empty());
890 assert_eq!(map.iter().count(), 0);
891 }
892
893 #[proptest]
894 fn test_last(set: RangeMap<u64, String>) {
895 assert_eq!(
896 set.last_range_value(),
897 set.iter().max_by_key(|(range, _)| range.end)
898 );
899 }
900
901 #[proptest]
902 fn test_iter_reversible(set: RangeMap<u64, String>) {
903 let forward: Vec<_> = set.iter().collect();
904 let mut backward: Vec<_> = set.iter().rev().collect();
905 backward.reverse();
906 assert_eq!(forward, backward);
907 }
908
909 #[proptest]
910 fn test_into_iter_reversible(set: RangeMap<u64, String>) {
911 let forward: Vec<_> = set.clone().into_iter().collect();
912 let mut backward: Vec<_> = set.into_iter().rev().collect();
913 backward.reverse();
914 assert_eq!(forward, backward);
915 }
916
917 #[proptest]
918 fn test_overlapping_reversible(set: RangeMap<u64, String>, range: Range<u64>) {
919 let forward: Vec<_> = set.overlapping(&range).collect();
920 let mut backward: Vec<_> = set.overlapping(&range).rev().collect();
921 backward.reverse();
922 assert_eq!(forward, backward);
923 }
924
925 #[proptest]
926 fn test_arbitrary_map_u8(ranges: Vec<(Range<u8>, String)>) {
927 let ranges: Vec<_> = ranges
928 .into_iter()
929 .filter(|(range, _value)| range.start != range.end)
930 .collect();
931 let set = ranges
932 .iter()
933 .fold(RangeMap::new(), |mut set, (range, value)| {
934 set.insert(range.clone(), value.clone());
935 set
936 });
937
938 for value in 0..u8::MAX {
939 assert_eq!(
940 set.get(&value),
941 ranges
942 .iter()
943 .rev()
944 .find(|(range, _value)| range.contains(&value))
945 .map(|(_range, value)| value)
946 );
947 }
948 }
949
950 #[proptest]
951 #[allow(deprecated)]
952 fn test_hash(left: RangeMap<u64, u64>, right: RangeMap<u64, u64>) {
953 use core::hash::{Hash, Hasher, SipHasher};
954
955 let hash = |set: &RangeMap<_, _>| {
956 let mut hasher = SipHasher::new();
957 set.hash(&mut hasher);
958 hasher.finish()
959 };
960
961 if left == right {
962 assert!(
963 hash(&left) == hash(&right),
964 "if two values are equal, their hash must be equal"
965 );
966 }
967
968 // if the hashes are equal the values might not be the same (collision)
969 if hash(&left) != hash(&right) {
970 assert!(
971 left != right,
972 "if two value's hashes are not equal, they must not be equal"
973 );
974 }
975 }
976
977 #[proptest]
978 fn test_ord(left: RangeMap<u64, u64>, right: RangeMap<u64, u64>) {
979 assert_eq!(
980 left == right,
981 left.cmp(&right).is_eq(),
982 "ordering and equality must match"
983 );
984 assert_eq!(
985 left.cmp(&right),
986 left.partial_cmp(&right).unwrap(),
987 "ordering is total for ordered parameters"
988 );
•989 }*/
990
991 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
992 fn test_from_arrayrust-analyzer cargo rangemap 1.7.1 map/tests/test_from_array().() {
993 let mut map = RangeMaprust-analyzer cargo rangemap 1.7.1 map/RangeMap#::newrust-analyzer cargo rangemap 1.7.1 map/impl#[`RangeMap<K, V>`]new().();
994 map.insertrust-analyzer cargo rangemap 1.7.1 map/impl#[`RangeMap<K, V>`]insert().(0..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#100, "hello");
995 map.insertrust-analyzer cargo rangemap 1.7.1 map/impl#[`RangeMap<K, V>`]insert().(200..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#300, "world");
996 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(
997 map,
998 RangeMaprust-analyzer cargo rangemap 1.7.1 map/RangeMap#::fromrust-analyzer cargo rangemap 1.7.1 map/impl#[`RangeMap<K, V>`][`From<[(Range<K>, V); N]>`]from().([(0..100, "hello"), (200..300, "world")])
999 );
1000 }
1001
1002 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
1003 fn test_macrorust-analyzer cargo rangemap 1.7.1 map/tests/test_macro().() {
1004 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(range_maprust-analyzer cargo rangemap 1.7.1 map/range_map!![], RangeMaprust-analyzer cargo rangemap 1.7.1 map/RangeMap#::<i64, i64>::defaultrust-analyzer cargo rangemap 1.7.1 map/impl#[`RangeMap<K, V>`][Default]default().());
1005 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(
1006 range_maprust-analyzer cargo rangemap 1.7.1 map/range_map!!(0..100 => "abc", 100..200 => "def", 200..300 => "ghi"),
1007 [(0..100, "abc"), (100..200, "def"), (200..300, "ghi")]
1008 .iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter().()
1009 .clonedrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#cloned().()
1010 .collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().(),
1011 );
1012 }
1013
1014 trait RangeMapExtrust-analyzer cargo rangemap 1.7.1 map/tests/RangeMapExt#<K, V> {
1015 fn to_vecrust-analyzer cargo rangemap 1.7.1 map/tests/RangeMapExt#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#<K>, V)>;
1016 }
1017
1018 impl<K, V> RangeMapExtrust-analyzer cargo rangemap 1.7.1 map/tests/RangeMapExt#<K, V> for RangeMaprust-analyzer cargo rangemap 1.7.1 map/RangeMap#<K, V>
1019 where
1020 K: 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#,
1021 V: PartialEqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq# + Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone#,
1022 {
1023 fn to_vecrust-analyzer cargo rangemap 1.7.1 map/tests/impl#[`RangeMap<K, V>`][`RangeMapExt<K, V>`]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#<K>, V)> {
1024 self.iterrust-analyzer cargo rangemap 1.7.1 map/impl#[`RangeMap<K, V>`]iter().().maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#map().(|(kr, v)| (kr.clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/impl#[`Range<Idx>`][Clone]clone().(), v.clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone#clone().())).collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().()
1025 }
1026 }
1027
1028 //
1029 // Insertion tests
1030 //
1031
1032 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
1033 fn empty_map_is_emptyrust-analyzer cargo rangemap 1.7.1 map/tests/empty_map_is_empty().() {
1034 let range_map: RangeMaprust-analyzer cargo rangemap 1.7.1 map/RangeMap#<u32, bool> = RangeMaprust-analyzer cargo rangemap 1.7.1 map/RangeMap#::newrust-analyzer cargo rangemap 1.7.1 map/impl#[`RangeMap<K, V>`]new().();
1035 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(range_map.to_vecrust-analyzer cargo rangemap 1.7.1 map/tests/impl#[`RangeMap<K, V>`][`RangeMapExt<K, V>`]to_vec().(), vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![]);
1036 }
1037
1038 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
1039 fn insert_into_empty_maprust-analyzer cargo rangemap 1.7.1 map/tests/insert_into_empty_map().() {
1040 let mut range_map: RangeMaprust-analyzer cargo rangemap 1.7.1 map/RangeMap#<u32, bool> = RangeMaprust-analyzer cargo rangemap 1.7.1 map/RangeMap#::newrust-analyzer cargo rangemap 1.7.1 map/impl#[`RangeMap<K, V>`]new().();
1041 range_map.insertrust-analyzer cargo rangemap 1.7.1 map/impl#[`RangeMap<K, V>`]insert().(0..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#50, false);
1042 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(range_map.to_vecrust-analyzer cargo rangemap 1.7.1 map/tests/impl#[`RangeMap<K, V>`][`RangeMapExt<K, V>`]to_vec().(), vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![(0..50, false)]);
1043 }
1044
1045 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
1046 fn new_same_value_immediately_following_storedrust-analyzer cargo rangemap 1.7.1 map/tests/new_same_value_immediately_following_stored().() {
1047 let mut range_map: RangeMaprust-analyzer cargo rangemap 1.7.1 map/RangeMap#<u32, bool> = RangeMaprust-analyzer cargo rangemap 1.7.1 map/RangeMap#::newrust-analyzer cargo rangemap 1.7.1 map/impl#[`RangeMap<K, V>`]new().();
1048 // 0 1 2 3 4 5 6 7 8 9
1049 // ◌ ●---◌ ◌ ◌ ◌ ◌ ◌ ◌
1050 range_map.insertrust-analyzer cargo rangemap 1.7.1 map/impl#[`RangeMap<K, V>`]insert().(1..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#3, false);
1051 // 0 1 2 3 4 5 6 7 8 9
1052 // ◌ ◌ ◌ ●---◌ ◌ ◌ ◌ ◌
1053 range_map.insertrust-analyzer cargo rangemap 1.7.1 map/impl#[`RangeMap<K, V>`]insert().(3..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#5, false);
1054 // 0 1 2 3 4 5 6 7 8 9
1055 // ◌ ●-------◌ ◌ ◌ ◌ ◌
1056 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(range_map.to_vecrust-analyzer cargo rangemap 1.7.1 map/tests/impl#[`RangeMap<K, V>`][`RangeMapExt<K, V>`]to_vec().(), vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![(1..5, false)]);
1057 }
1058
1059 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
1060 fn new_different_value_immediately_following_storedrust-analyzer cargo rangemap 1.7.1 map/tests/new_different_value_immediately_following_stored().() {
1061 let mut range_map: RangeMaprust-analyzer cargo rangemap 1.7.1 map/RangeMap#<u32, bool> = RangeMaprust-analyzer cargo rangemap 1.7.1 map/RangeMap#::newrust-analyzer cargo rangemap 1.7.1 map/impl#[`RangeMap<K, V>`]new().();
1062 // 0 1 2 3 4 5 6 7 8 9
1063 // ◌ ●---◌ ◌ ◌ ◌ ◌ ◌ ◌
1064 range_map.insertrust-analyzer cargo rangemap 1.7.1 map/impl#[`RangeMap<K, V>`]insert().(1..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#3, false);
1065 // 0 1 2 3 4 5 6 7 8 9
1066 // ◌ ◌ ◌ ◆---◇ ◌ ◌ ◌ ◌
1067 range_map.insertrust-analyzer cargo rangemap 1.7.1 map/impl#[`RangeMap<K, V>`]insert().(3..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#5, true);
1068 // 0 1 2 3 4 5 6 7 8 9
1069 // ◌ ●---◌ ◌ ◌ ◌ ◌ ◌ ◌
1070 // ◌ ◌ ◌ ◆---◇ ◌ ◌ ◌ ◌
1071 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(range_map.to_vecrust-analyzer cargo rangemap 1.7.1 map/tests/impl#[`RangeMap<K, V>`][`RangeMapExt<K, V>`]to_vec().(), vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![(1..3, false), (3..5, true)]);
1072 }
1073
1074 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
1075 fn new_same_value_overlapping_end_of_storedrust-analyzer cargo rangemap 1.7.1 map/tests/new_same_value_overlapping_end_of_stored().() {
1076 let mut range_map: RangeMaprust-analyzer cargo rangemap 1.7.1 map/RangeMap#<u32, bool> = RangeMaprust-analyzer cargo rangemap 1.7.1 map/RangeMap#::newrust-analyzer cargo rangemap 1.7.1 map/impl#[`RangeMap<K, V>`]new().();
1077 // 0 1 2 3 4 5 6 7 8 9
1078 // ◌ ●-----◌ ◌ ◌ ◌ ◌ ◌
1079 range_map.insertrust-analyzer cargo rangemap 1.7.1 map/impl#[`RangeMap<K, V>`]insert().(1..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#4, false);
1080 // 0 1 2 3 4 5 6 7 8 9
1081 // ◌ ◌ ◌ ●---◌ ◌ ◌ ◌ ◌
1082 range_map.insertrust-analyzer cargo rangemap 1.7.1 map/impl#[`RangeMap<K, V>`]insert().(3..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#5, false);
1083 // 0 1 2 3 4 5 6 7 8 9
1084 // ◌ ●-------◌ ◌ ◌ ◌ ◌
1085 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(range_map.to_vecrust-analyzer cargo rangemap 1.7.1 map/tests/impl#[`RangeMap<K, V>`][`RangeMapExt<K, V>`]to_vec().(), vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![(1..5, false)]);
1086 }
1087
1088 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
1089 fn new_different_value_overlapping_end_of_storedrust-analyzer cargo rangemap 1.7.1 map/tests/new_different_value_overlapping_end_of_stored().() {
1090 let mut range_map: RangeMaprust-analyzer cargo rangemap 1.7.1 map/RangeMap#<u32, bool> = RangeMaprust-analyzer cargo rangemap 1.7.1 map/RangeMap#::newrust-analyzer cargo rangemap 1.7.1 map/impl#[`RangeMap<K, V>`]new().();
1091 // 0 1 2 3 4 5 6 7 8 9
1092 // ◌ ●-----◌ ◌ ◌ ◌ ◌ ◌
1093 range_map.insertrust-analyzer cargo rangemap 1.7.1 map/impl#[`RangeMap<K, V>`]insert().(1..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#4, false);
1094 // 0 1 2 3 4 5 6 7 8 9
1095 // ◌ ◌ ◌ ◆---◇ ◌ ◌ ◌ ◌
1096 range_map.insertrust-analyzer cargo rangemap 1.7.1 map/impl#[`RangeMap<K, V>`]insert().(3..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#5, true);
1097 // 0 1 2 3 4 5 6 7 8 9
1098 // ◌ ●---◌ ◌ ◌ ◌ ◌ ◌ ◌
1099 // ◌ ◌ ◌ ◆---◇ ◌ ◌ ◌ ◌
1100 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(range_map.to_vecrust-analyzer cargo rangemap 1.7.1 map/tests/impl#[`RangeMap<K, V>`][`RangeMapExt<K, V>`]to_vec().(), vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![(1..3, false), (3..5, true)]);
1101 }
1102
1103 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
1104 fn new_same_value_immediately_preceding_storedrust-analyzer cargo rangemap 1.7.1 map/tests/new_same_value_immediately_preceding_stored().() {
1105 let mut range_map: RangeMaprust-analyzer cargo rangemap 1.7.1 map/RangeMap#<u32, bool> = RangeMaprust-analyzer cargo rangemap 1.7.1 map/RangeMap#::newrust-analyzer cargo rangemap 1.7.1 map/impl#[`RangeMap<K, V>`]new().();
1106 // 0 1 2 3 4 5 6 7 8 9
1107 // ◌ ◌ ◌ ●---◌ ◌ ◌ ◌ ◌
1108 range_map.insertrust-analyzer cargo rangemap 1.7.1 map/impl#[`RangeMap<K, V>`]insert().(3..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#5, false);
1109 // 0 1 2 3 4 5 6 7 8 9
1110 // ◌ ●---◌ ◌ ◌ ◌ ◌ ◌ ◌
1111 range_map.insertrust-analyzer cargo rangemap 1.7.1 map/impl#[`RangeMap<K, V>`]insert().(1..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#3, false);
1112 // 0 1 2 3 4 5 6 7 8 9
1113 // ◌ ●-------◌ ◌ ◌ ◌ ◌
1114 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(range_map.to_vecrust-analyzer cargo rangemap 1.7.1 map/tests/impl#[`RangeMap<K, V>`][`RangeMapExt<K, V>`]to_vec().(), vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![(1..5, false)]);
1115 }
1116
1117 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
1118 fn new_different_value_immediately_preceding_storedrust-analyzer cargo rangemap 1.7.1 map/tests/new_different_value_immediately_preceding_stored().() {
1119 let mut range_map: RangeMaprust-analyzer cargo rangemap 1.7.1 map/RangeMap#<u32, bool> = RangeMaprust-analyzer cargo rangemap 1.7.1 map/RangeMap#::newrust-analyzer cargo rangemap 1.7.1 map/impl#[`RangeMap<K, V>`]new().();
1120 // 0 1 2 3 4 5 6 7 8 9
1121 // ◌ ◌ ◌ ◆---◇ ◌ ◌ ◌ ◌
1122 range_map.insertrust-analyzer cargo rangemap 1.7.1 map/impl#[`RangeMap<K, V>`]insert().(3..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#5, true);
1123 // 0 1 2 3 4 5 6 7 8 9
1124 // ◌ ●---◌ ◌ ◌ ◌ ◌ ◌ ◌
1125 range_map.insertrust-analyzer cargo rangemap 1.7.1 map/impl#[`RangeMap<K, V>`]insert().(1..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#3, false);
1126 // 0 1 2 3 4 5 6 7 8 9
1127 // ◌ ●---◌ ◌ ◌ ◌ ◌ ◌ ◌
1128 // ◌ ◌ ◌ ◆---◇ ◌ ◌ ◌ ◌
1129 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(range_map.to_vecrust-analyzer cargo rangemap 1.7.1 map/tests/impl#[`RangeMap<K, V>`][`RangeMapExt<K, V>`]to_vec().(), vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![(1..3, false), (3..5, true)]);
1130 }
1131
1132 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
1133 fn new_same_value_wholly_inside_storedrust-analyzer cargo rangemap 1.7.1 map/tests/new_same_value_wholly_inside_stored().() {
1134 let mut range_map: RangeMaprust-analyzer cargo rangemap 1.7.1 map/RangeMap#<u32, bool> = RangeMaprust-analyzer cargo rangemap 1.7.1 map/RangeMap#::newrust-analyzer cargo rangemap 1.7.1 map/impl#[`RangeMap<K, V>`]new().();
1135 // 0 1 2 3 4 5 6 7 8 9
1136 // ◌ ●-------◌ ◌ ◌ ◌ ◌
1137 range_map.insertrust-analyzer cargo rangemap 1.7.1 map/impl#[`RangeMap<K, V>`]insert().(1..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#5, false);
1138 // 0 1 2 3 4 5 6 7 8 9
1139 // ◌ ◌ ●---◌ ◌ ◌ ◌ ◌ ◌ ◌
1140 range_map.insertrust-analyzer cargo rangemap 1.7.1 map/impl#[`RangeMap<K, V>`]insert().(2..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#4, false);
1141 // 0 1 2 3 4 5 6 7 8 9
1142 // ◌ ●-------◌ ◌ ◌ ◌ ◌
1143 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(range_map.to_vecrust-analyzer cargo rangemap 1.7.1 map/tests/impl#[`RangeMap<K, V>`][`RangeMapExt<K, V>`]to_vec().(), vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![(1..5, false)]);
1144 }
1145
1146 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
1147 fn new_different_value_wholly_inside_storedrust-analyzer cargo rangemap 1.7.1 map/tests/new_different_value_wholly_inside_stored().() {
1148 let mut range_map: RangeMaprust-analyzer cargo rangemap 1.7.1 map/RangeMap#<u32, bool> = RangeMaprust-analyzer cargo rangemap 1.7.1 map/RangeMap#::newrust-analyzer cargo rangemap 1.7.1 map/impl#[`RangeMap<K, V>`]new().();
1149 // 0 1 2 3 4 5 6 7 8 9
1150 // ◌ ◆-------◇ ◌ ◌ ◌ ◌
1151 range_map.insertrust-analyzer cargo rangemap 1.7.1 map/impl#[`RangeMap<K, V>`]insert().(1..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#5, true);
1152 // 0 1 2 3 4 5 6 7 8 9
1153 // ◌ ◌ ●---◌ ◌ ◌ ◌ ◌ ◌ ◌
1154 range_map.insertrust-analyzer cargo rangemap 1.7.1 map/impl#[`RangeMap<K, V>`]insert().(2..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#4, false);
1155 // 0 1 2 3 4 5 6 7 8 9
1156 // ◌ ●-◌ ◌ ◌ ◌ ◌ ◌ ◌ ◌
1157 // ◌ ◌ ◆---◇ ◌ ◌ ◌ ◌ ◌
1158 // ◌ ◌ ◌ ◌ ●-◌ ◌ ◌ ◌ ◌
1159 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(
1160 range_map.to_vecrust-analyzer cargo rangemap 1.7.1 map/tests/impl#[`RangeMap<K, V>`][`RangeMapExt<K, V>`]to_vec().(),
1161 vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![(1..2, true), (2..4, false), (4..5, true)]
1162 );
1163 }
1164
1165 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
1166 fn replace_at_end_of_existing_range_should_coalescerust-analyzer cargo rangemap 1.7.1 map/tests/replace_at_end_of_existing_range_should_coalesce().() {
1167 let mut range_map: RangeMaprust-analyzer cargo rangemap 1.7.1 map/RangeMap#<u32, bool> = RangeMaprust-analyzer cargo rangemap 1.7.1 map/RangeMap#::newrust-analyzer cargo rangemap 1.7.1 map/impl#[`RangeMap<K, V>`]new().();
1168 // 0 1 2 3 4 5 6 7 8 9
1169 // ◌ ●---◌ ◌ ◌ ◌ ◌ ◌ ◌
1170 range_map.insertrust-analyzer cargo rangemap 1.7.1 map/impl#[`RangeMap<K, V>`]insert().(1..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#3, false);
1171 // 0 1 2 3 4 5 6 7 8 9
1172 // ◌ ◌ ◌ ●---◌ ◌ ◌ ◌ ◌
1173 range_map.insertrust-analyzer cargo rangemap 1.7.1 map/impl#[`RangeMap<K, V>`]insert().(3..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#5, true);
1174 // 0 1 2 3 4 5 6 7 8 9
1175 // ◌ ◌ ◌ ●---◌ ◌ ◌ ◌ ◌
1176 range_map.insertrust-analyzer cargo rangemap 1.7.1 map/impl#[`RangeMap<K, V>`]insert().(3..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#5, false);
1177 // 0 1 2 3 4 5 6 7 8 9
1178 // ◌ ●-------◌ ◌ ◌ ◌ ◌
1179 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(range_map.to_vecrust-analyzer cargo rangemap 1.7.1 map/tests/impl#[`RangeMap<K, V>`][`RangeMapExt<K, V>`]to_vec().(), vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![(1..5, false)]);
1180 }
1181
•1182 /*#[test]
1183 // Test every permutation of a bunch of touching and overlapping ranges.
1184 fn lots_of_interesting_ranges() {
1185 use crate::dense::DenseU32RangeMap;
1186 use permutator::Permutation;
1187
1188 let mut ranges_with_values = [
1189 (2..3, false),
1190 // A duplicate duplicates
1191 (2..3, false),
1192 // Almost a duplicate, but with a different value
1193 (2..3, true),
1194 // A few small ranges, some of them overlapping others,
1195 // some of them touching others
1196 (3..5, true),
1197 (4..6, true),
1198 (5..7, true),
1199 // A really big range
1200 (2..6, true),
1201 ];
1202
1203 ranges_with_values.permutation().for_each(|permutation| {
1204 let mut range_map: RangeMap<u32, bool> = RangeMap::new();
1205 let mut dense: DenseU32RangeMap<bool> = DenseU32RangeMap::new();
1206
1207 for (k, v) in permutation {
1208 // Insert it into both maps.
1209 range_map.insert(k.clone(), v);
1210 // NOTE: Clippy's `range_minus_one` lint is a bit overzealous here,
1211 // because we _can't_ pass an open-ended range to `insert`.
1212 #[allow(clippy::range_minus_one)]
1213 dense.insert(k.start..=(k.end - 1), v);
1214
1215 // At every step, both maps should contain the same stuff.
1216 let sparse = range_map.to_vec();
1217 let dense = dense.to_end_exclusive_vec();
1218 assert_eq!(sparse, dense);
1219 }
1220 });
•1221 }*/
1222
1223 //
1224 // Get* tests
1225 //
1226
1227 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
1228 fn getrust-analyzer cargo rangemap 1.7.1 map/tests/get().() {
1229 let mut range_map: RangeMaprust-analyzer cargo rangemap 1.7.1 map/RangeMap#<u32, bool> = RangeMaprust-analyzer cargo rangemap 1.7.1 map/RangeMap#::newrust-analyzer cargo rangemap 1.7.1 map/impl#[`RangeMap<K, V>`]new().();
1230 range_map.insertrust-analyzer cargo rangemap 1.7.1 map/impl#[`RangeMap<K, V>`]insert().(0..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#50, false);
1231 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(range_map.getrust-analyzer cargo rangemap 1.7.1 map/impl#[`RangeMap<K, V>`]get().(&49), Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(&false));
1232 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(range_map.getrust-analyzer cargo rangemap 1.7.1 map/impl#[`RangeMap<K, V>`]get().(&50), Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#);
1233 }
1234
1235 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
1236 fn get_key_valuerust-analyzer cargo rangemap 1.7.1 map/tests/get_key_value().() {
1237 let mut range_map: RangeMaprust-analyzer cargo rangemap 1.7.1 map/RangeMap#<u32, bool> = RangeMaprust-analyzer cargo rangemap 1.7.1 map/RangeMap#::newrust-analyzer cargo rangemap 1.7.1 map/impl#[`RangeMap<K, V>`]new().();
1238 range_map.insertrust-analyzer cargo rangemap 1.7.1 map/impl#[`RangeMap<K, V>`]insert().(0..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#50, false);
1239 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(range_map.get_key_valuerust-analyzer cargo rangemap 1.7.1 map/impl#[`RangeMap<K, V>`]get_key_value().(&49), Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#((&(0..50), &false)));
1240 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(range_map.get_key_valuerust-analyzer cargo rangemap 1.7.1 map/impl#[`RangeMap<K, V>`]get_key_value().(&50), Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#);
1241 }
1242
1243 //
1244 // Removal tests
1245 //
1246
1247 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
1248 fn remove_from_empty_maprust-analyzer cargo rangemap 1.7.1 map/tests/remove_from_empty_map().() {
1249 let mut range_map: RangeMaprust-analyzer cargo rangemap 1.7.1 map/RangeMap#<u32, bool> = RangeMaprust-analyzer cargo rangemap 1.7.1 map/RangeMap#::newrust-analyzer cargo rangemap 1.7.1 map/impl#[`RangeMap<K, V>`]new().();
1250 range_map.removerust-analyzer cargo rangemap 1.7.1 map/impl#[`RangeMap<K, V>`]remove().(0..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#50);
1251 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(range_map.to_vecrust-analyzer cargo rangemap 1.7.1 map/tests/impl#[`RangeMap<K, V>`][`RangeMapExt<K, V>`]to_vec().(), vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![]);
1252 }
1253
1254 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
1255 fn remove_non_covered_range_before_storedrust-analyzer cargo rangemap 1.7.1 map/tests/remove_non_covered_range_before_stored().() {
1256 let mut range_map: RangeMaprust-analyzer cargo rangemap 1.7.1 map/RangeMap#<u32, bool> = RangeMaprust-analyzer cargo rangemap 1.7.1 map/RangeMap#::newrust-analyzer cargo rangemap 1.7.1 map/impl#[`RangeMap<K, V>`]new().();
1257 range_map.insertrust-analyzer cargo rangemap 1.7.1 map/impl#[`RangeMap<K, V>`]insert().(25..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#75, false);
1258 range_map.removerust-analyzer cargo rangemap 1.7.1 map/impl#[`RangeMap<K, V>`]remove().(0..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#25);
1259 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(range_map.to_vecrust-analyzer cargo rangemap 1.7.1 map/tests/impl#[`RangeMap<K, V>`][`RangeMapExt<K, V>`]to_vec().(), vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![(25..75, false)]);
1260 }
1261
1262 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
1263 fn remove_non_covered_range_after_storedrust-analyzer cargo rangemap 1.7.1 map/tests/remove_non_covered_range_after_stored().() {
1264 let mut range_map: RangeMaprust-analyzer cargo rangemap 1.7.1 map/RangeMap#<u32, bool> = RangeMaprust-analyzer cargo rangemap 1.7.1 map/RangeMap#::newrust-analyzer cargo rangemap 1.7.1 map/impl#[`RangeMap<K, V>`]new().();
1265 range_map.insertrust-analyzer cargo rangemap 1.7.1 map/impl#[`RangeMap<K, V>`]insert().(25..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#75, false);
1266 range_map.removerust-analyzer cargo rangemap 1.7.1 map/impl#[`RangeMap<K, V>`]remove().(75..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#100);
1267 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(range_map.to_vecrust-analyzer cargo rangemap 1.7.1 map/tests/impl#[`RangeMap<K, V>`][`RangeMapExt<K, V>`]to_vec().(), vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![(25..75, false)]);
1268 }
1269
1270 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
1271 fn remove_overlapping_start_of_storedrust-analyzer cargo rangemap 1.7.1 map/tests/remove_overlapping_start_of_stored().() {
1272 let mut range_map: RangeMaprust-analyzer cargo rangemap 1.7.1 map/RangeMap#<u32, bool> = RangeMaprust-analyzer cargo rangemap 1.7.1 map/RangeMap#::newrust-analyzer cargo rangemap 1.7.1 map/impl#[`RangeMap<K, V>`]new().();
1273 range_map.insertrust-analyzer cargo rangemap 1.7.1 map/impl#[`RangeMap<K, V>`]insert().(25..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#75, false);
1274 range_map.removerust-analyzer cargo rangemap 1.7.1 map/impl#[`RangeMap<K, V>`]remove().(0..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#30);
1275 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(range_map.to_vecrust-analyzer cargo rangemap 1.7.1 map/tests/impl#[`RangeMap<K, V>`][`RangeMapExt<K, V>`]to_vec().(), vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![(30..75, false)]);
1276 }
1277
1278 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
1279 fn remove_middle_of_storedrust-analyzer cargo rangemap 1.7.1 map/tests/remove_middle_of_stored().() {
1280 let mut range_map: RangeMaprust-analyzer cargo rangemap 1.7.1 map/RangeMap#<u32, bool> = RangeMaprust-analyzer cargo rangemap 1.7.1 map/RangeMap#::newrust-analyzer cargo rangemap 1.7.1 map/impl#[`RangeMap<K, V>`]new().();
1281 range_map.insertrust-analyzer cargo rangemap 1.7.1 map/impl#[`RangeMap<K, V>`]insert().(25..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#75, false);
1282 range_map.removerust-analyzer cargo rangemap 1.7.1 map/impl#[`RangeMap<K, V>`]remove().(30..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#70);
1283 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(range_map.to_vecrust-analyzer cargo rangemap 1.7.1 map/tests/impl#[`RangeMap<K, V>`][`RangeMapExt<K, V>`]to_vec().(), vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![(25..30, false), (70..75, false)]);
1284 }
1285
1286 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
1287 fn remove_overlapping_end_of_storedrust-analyzer cargo rangemap 1.7.1 map/tests/remove_overlapping_end_of_stored().() {
1288 let mut range_map: RangeMaprust-analyzer cargo rangemap 1.7.1 map/RangeMap#<u32, bool> = RangeMaprust-analyzer cargo rangemap 1.7.1 map/RangeMap#::newrust-analyzer cargo rangemap 1.7.1 map/impl#[`RangeMap<K, V>`]new().();
1289 range_map.insertrust-analyzer cargo rangemap 1.7.1 map/impl#[`RangeMap<K, V>`]insert().(25..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#75, false);
1290 range_map.removerust-analyzer cargo rangemap 1.7.1 map/impl#[`RangeMap<K, V>`]remove().(70..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#100);
1291 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(range_map.to_vecrust-analyzer cargo rangemap 1.7.1 map/tests/impl#[`RangeMap<K, V>`][`RangeMapExt<K, V>`]to_vec().(), vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![(25..70, false)]);
1292 }
1293
1294 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
1295 fn remove_exactly_storedrust-analyzer cargo rangemap 1.7.1 map/tests/remove_exactly_stored().() {
1296 let mut range_map: RangeMaprust-analyzer cargo rangemap 1.7.1 map/RangeMap#<u32, bool> = RangeMaprust-analyzer cargo rangemap 1.7.1 map/RangeMap#::newrust-analyzer cargo rangemap 1.7.1 map/impl#[`RangeMap<K, V>`]new().();
1297 range_map.insertrust-analyzer cargo rangemap 1.7.1 map/impl#[`RangeMap<K, V>`]insert().(25..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#75, false);
1298 range_map.removerust-analyzer cargo rangemap 1.7.1 map/impl#[`RangeMap<K, V>`]remove().(25..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#75);
1299 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(range_map.to_vecrust-analyzer cargo rangemap 1.7.1 map/tests/impl#[`RangeMap<K, V>`][`RangeMapExt<K, V>`]to_vec().(), vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![]);
1300 }
1301
1302 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
1303 fn remove_superset_of_storedrust-analyzer cargo rangemap 1.7.1 map/tests/remove_superset_of_stored().() {
1304 let mut range_map: RangeMaprust-analyzer cargo rangemap 1.7.1 map/RangeMap#<u32, bool> = RangeMaprust-analyzer cargo rangemap 1.7.1 map/RangeMap#::newrust-analyzer cargo rangemap 1.7.1 map/impl#[`RangeMap<K, V>`]new().();
1305 range_map.insertrust-analyzer cargo rangemap 1.7.1 map/impl#[`RangeMap<K, V>`]insert().(25..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#75, false);
1306 range_map.removerust-analyzer cargo rangemap 1.7.1 map/impl#[`RangeMap<K, V>`]remove().(0..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#100);
1307 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(range_map.to_vecrust-analyzer cargo rangemap 1.7.1 map/tests/impl#[`RangeMap<K, V>`][`RangeMapExt<K, V>`]to_vec().(), vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![]);
1308 }
1309
1310 // Gaps tests
1311
1312 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
1313 fn whole_range_is_a_gaprust-analyzer cargo rangemap 1.7.1 map/tests/whole_range_is_a_gap().() {
1314 // 0 1 2 3 4 5 6 7 8 9
1315 // ◌ ◌ ◌ ◌ ◌ ◌ ◌ ◌ ◌ ◌
1316 let range_map: RangeMaprust-analyzer cargo rangemap 1.7.1 map/RangeMap#<u32, ()> = RangeMaprust-analyzer cargo rangemap 1.7.1 map/RangeMap#::newrust-analyzer cargo rangemap 1.7.1 map/impl#[`RangeMap<K, V>`]new().();
1317 // 0 1 2 3 4 5 6 7 8 9
1318 // ◌ ◆-------------◇ ◌
1319 let outer_range = 1..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#8;
1320 let mut gaps = range_map.gapsrust-analyzer cargo rangemap 1.7.1 map/impl#[`RangeMap<K, V>`]gaps().(&outer_range);
1321 // Should yield the entire outer range.
1322 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(gaps.nextrust-analyzer cargo rangemap 1.7.1 map/impl#[`Gaps<'a, K, V>`][Iterator]next().(), Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(1..8));
1323 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(gaps.nextrust-analyzer cargo rangemap 1.7.1 map/impl#[`Gaps<'a, K, V>`][Iterator]next().(), Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#);
1324 // Gaps iterator should be fused.
1325 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(gaps.nextrust-analyzer cargo rangemap 1.7.1 map/impl#[`Gaps<'a, K, V>`][Iterator]next().(), Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#);
1326 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(gaps.nextrust-analyzer cargo rangemap 1.7.1 map/impl#[`Gaps<'a, K, V>`][Iterator]next().(), Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#);
1327 }
1328
1329 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
1330 fn whole_range_is_covered_exactlyrust-analyzer cargo rangemap 1.7.1 map/tests/whole_range_is_covered_exactly().() {
1331 let mut range_map: RangeMaprust-analyzer cargo rangemap 1.7.1 map/RangeMap#<u32, ()> = RangeMaprust-analyzer cargo rangemap 1.7.1 map/RangeMap#::newrust-analyzer cargo rangemap 1.7.1 map/impl#[`RangeMap<K, V>`]new().();
1332 // 0 1 2 3 4 5 6 7 8 9
1333 // ◌ ●---------◌ ◌ ◌ ◌
1334 range_map.insertrust-analyzer cargo rangemap 1.7.1 map/impl#[`RangeMap<K, V>`]insert().(1..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#6, ());
1335 // 0 1 2 3 4 5 6 7 8 9
1336 // ◌ ◆---------◇ ◌ ◌ ◌
1337 let outer_range = 1..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#6;
1338 let mut gaps = range_map.gapsrust-analyzer cargo rangemap 1.7.1 map/impl#[`RangeMap<K, V>`]gaps().(&outer_range);
1339 // Should yield no gaps.
1340 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(gaps.nextrust-analyzer cargo rangemap 1.7.1 map/impl#[`Gaps<'a, K, V>`][Iterator]next().(), Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#);
1341 // Gaps iterator should be fused.
1342 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(gaps.nextrust-analyzer cargo rangemap 1.7.1 map/impl#[`Gaps<'a, K, V>`][Iterator]next().(), Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#);
1343 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(gaps.nextrust-analyzer cargo rangemap 1.7.1 map/impl#[`Gaps<'a, K, V>`][Iterator]next().(), Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#);
1344 }
1345
1346 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
1347 fn item_before_outer_rangerust-analyzer cargo rangemap 1.7.1 map/tests/item_before_outer_range().() {
1348 let mut range_map: RangeMaprust-analyzer cargo rangemap 1.7.1 map/RangeMap#<u32, ()> = RangeMaprust-analyzer cargo rangemap 1.7.1 map/RangeMap#::newrust-analyzer cargo rangemap 1.7.1 map/impl#[`RangeMap<K, V>`]new().();
1349 // 0 1 2 3 4 5 6 7 8 9
1350 // ◌ ●---◌ ◌ ◌ ◌ ◌ ◌ ◌
1351 range_map.insertrust-analyzer cargo rangemap 1.7.1 map/impl#[`RangeMap<K, V>`]insert().(1..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#3, ());
1352 // 0 1 2 3 4 5 6 7 8 9
1353 // ◌ ◌ ◌ ◌ ◌ ◆-----◇ ◌
1354 let outer_range = 5..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#8;
1355 let mut gaps = range_map.gapsrust-analyzer cargo rangemap 1.7.1 map/impl#[`RangeMap<K, V>`]gaps().(&outer_range);
1356 // Should yield the entire outer range.
1357 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(gaps.nextrust-analyzer cargo rangemap 1.7.1 map/impl#[`Gaps<'a, K, V>`][Iterator]next().(), Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(5..8));
1358 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(gaps.nextrust-analyzer cargo rangemap 1.7.1 map/impl#[`Gaps<'a, K, V>`][Iterator]next().(), Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#);
1359 // Gaps iterator should be fused.
1360 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(gaps.nextrust-analyzer cargo rangemap 1.7.1 map/impl#[`Gaps<'a, K, V>`][Iterator]next().(), Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#);
1361 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(gaps.nextrust-analyzer cargo rangemap 1.7.1 map/impl#[`Gaps<'a, K, V>`][Iterator]next().(), Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#);
1362 }
1363
1364 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
1365 fn item_touching_start_of_outer_rangerust-analyzer cargo rangemap 1.7.1 map/tests/item_touching_start_of_outer_range().() {
1366 let mut range_map: RangeMaprust-analyzer cargo rangemap 1.7.1 map/RangeMap#<u32, ()> = RangeMaprust-analyzer cargo rangemap 1.7.1 map/RangeMap#::newrust-analyzer cargo rangemap 1.7.1 map/impl#[`RangeMap<K, V>`]new().();
1367 // 0 1 2 3 4 5 6 7 8 9
1368 // ◌ ●-------◌ ◌ ◌ ◌ ◌
1369 range_map.insertrust-analyzer cargo rangemap 1.7.1 map/impl#[`RangeMap<K, V>`]insert().(1..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#5, ());
1370 // 0 1 2 3 4 5 6 7 8 9
1371 // ◌ ◌ ◌ ◌ ◌ ◆-----◇ ◌
1372 let outer_range = 5..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#8;
1373 let mut gaps = range_map.gapsrust-analyzer cargo rangemap 1.7.1 map/impl#[`RangeMap<K, V>`]gaps().(&outer_range);
1374 // Should yield the entire outer range.
1375 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(gaps.nextrust-analyzer cargo rangemap 1.7.1 map/impl#[`Gaps<'a, K, V>`][Iterator]next().(), Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(5..8));
1376 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(gaps.nextrust-analyzer cargo rangemap 1.7.1 map/impl#[`Gaps<'a, K, V>`][Iterator]next().(), Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#);
1377 // Gaps iterator should be fused.
1378 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(gaps.nextrust-analyzer cargo rangemap 1.7.1 map/impl#[`Gaps<'a, K, V>`][Iterator]next().(), Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#);
1379 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(gaps.nextrust-analyzer cargo rangemap 1.7.1 map/impl#[`Gaps<'a, K, V>`][Iterator]next().(), Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#);
1380 }
1381
1382 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
1383 fn item_overlapping_start_of_outer_rangerust-analyzer cargo rangemap 1.7.1 map/tests/item_overlapping_start_of_outer_range().() {
1384 let mut range_map: RangeMaprust-analyzer cargo rangemap 1.7.1 map/RangeMap#<u32, ()> = RangeMaprust-analyzer cargo rangemap 1.7.1 map/RangeMap#::newrust-analyzer cargo rangemap 1.7.1 map/impl#[`RangeMap<K, V>`]new().();
1385 // 0 1 2 3 4 5 6 7 8 9
1386 // ◌ ●---------◌ ◌ ◌ ◌
1387 range_map.insertrust-analyzer cargo rangemap 1.7.1 map/impl#[`RangeMap<K, V>`]insert().(1..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#6, ());
1388 // 0 1 2 3 4 5 6 7 8 9
1389 // ◌ ◌ ◌ ◌ ◌ ◆-----◇ ◌
1390 let outer_range = 5..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#8;
1391 let mut gaps = range_map.gapsrust-analyzer cargo rangemap 1.7.1 map/impl#[`RangeMap<K, V>`]gaps().(&outer_range);
1392 // Should yield from the end of the stored item
1393 // to the end of the outer range.
1394 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(gaps.nextrust-analyzer cargo rangemap 1.7.1 map/impl#[`Gaps<'a, K, V>`][Iterator]next().(), Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(6..8));
1395 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(gaps.nextrust-analyzer cargo rangemap 1.7.1 map/impl#[`Gaps<'a, K, V>`][Iterator]next().(), Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#);
1396 // Gaps iterator should be fused.
1397 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(gaps.nextrust-analyzer cargo rangemap 1.7.1 map/impl#[`Gaps<'a, K, V>`][Iterator]next().(), Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#);
1398 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(gaps.nextrust-analyzer cargo rangemap 1.7.1 map/impl#[`Gaps<'a, K, V>`][Iterator]next().(), Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#);
1399 }
1400
1401 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
1402 fn item_starting_at_start_of_outer_rangerust-analyzer cargo rangemap 1.7.1 map/tests/item_starting_at_start_of_outer_range().() {
1403 let mut range_map: RangeMaprust-analyzer cargo rangemap 1.7.1 map/RangeMap#<u32, ()> = RangeMaprust-analyzer cargo rangemap 1.7.1 map/RangeMap#::newrust-analyzer cargo rangemap 1.7.1 map/impl#[`RangeMap<K, V>`]new().();
1404 // 0 1 2 3 4 5 6 7 8 9
1405 // ◌ ◌ ◌ ◌ ◌ ●-◌ ◌ ◌ ◌
1406 range_map.insertrust-analyzer cargo rangemap 1.7.1 map/impl#[`RangeMap<K, V>`]insert().(5..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#6, ());
1407 // 0 1 2 3 4 5 6 7 8 9
1408 // ◌ ◌ ◌ ◌ ◌ ◆-----◇ ◌
1409 let outer_range = 5..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#8;
1410 let mut gaps = range_map.gapsrust-analyzer cargo rangemap 1.7.1 map/impl#[`RangeMap<K, V>`]gaps().(&outer_range);
1411 // Should yield from the item onwards.
1412 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(gaps.nextrust-analyzer cargo rangemap 1.7.1 map/impl#[`Gaps<'a, K, V>`][Iterator]next().(), Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(6..8));
1413 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(gaps.nextrust-analyzer cargo rangemap 1.7.1 map/impl#[`Gaps<'a, K, V>`][Iterator]next().(), Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#);
1414 // Gaps iterator should be fused.
1415 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(gaps.nextrust-analyzer cargo rangemap 1.7.1 map/impl#[`Gaps<'a, K, V>`][Iterator]next().(), Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#);
1416 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(gaps.nextrust-analyzer cargo rangemap 1.7.1 map/impl#[`Gaps<'a, K, V>`][Iterator]next().(), Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#);
1417 }
1418
1419 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
1420 fn items_floating_inside_outer_rangerust-analyzer cargo rangemap 1.7.1 map/tests/items_floating_inside_outer_range().() {
1421 let mut range_map: RangeMaprust-analyzer cargo rangemap 1.7.1 map/RangeMap#<u32, ()> = RangeMaprust-analyzer cargo rangemap 1.7.1 map/RangeMap#::newrust-analyzer cargo rangemap 1.7.1 map/impl#[`RangeMap<K, V>`]new().();
1422 // 0 1 2 3 4 5 6 7 8 9
1423 // ◌ ◌ ◌ ◌ ◌ ●-◌ ◌ ◌ ◌
1424 range_map.insertrust-analyzer cargo rangemap 1.7.1 map/impl#[`RangeMap<K, V>`]insert().(5..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#6, ());
1425 // 0 1 2 3 4 5 6 7 8 9
1426 // ◌ ◌ ◌ ●-◌ ◌ ◌ ◌ ◌ ◌
1427 range_map.insertrust-analyzer cargo rangemap 1.7.1 map/impl#[`RangeMap<K, V>`]insert().(3..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#4, ());
1428 // 0 1 2 3 4 5 6 7 8 9
1429 // ◌ ◆-------------◇ ◌
1430 let outer_range = 1..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#8;
1431 let mut gaps = range_map.gapsrust-analyzer cargo rangemap 1.7.1 map/impl#[`RangeMap<K, V>`]gaps().(&outer_range);
1432 // Should yield gaps at start, between items,
1433 // and at end.
1434 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(gaps.nextrust-analyzer cargo rangemap 1.7.1 map/impl#[`Gaps<'a, K, V>`][Iterator]next().(), Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(1..3));
1435 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(gaps.nextrust-analyzer cargo rangemap 1.7.1 map/impl#[`Gaps<'a, K, V>`][Iterator]next().(), Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(4..5));
1436 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(gaps.nextrust-analyzer cargo rangemap 1.7.1 map/impl#[`Gaps<'a, K, V>`][Iterator]next().(), Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(6..8));
1437 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(gaps.nextrust-analyzer cargo rangemap 1.7.1 map/impl#[`Gaps<'a, K, V>`][Iterator]next().(), Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#);
1438 // Gaps iterator should be fused.
1439 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(gaps.nextrust-analyzer cargo rangemap 1.7.1 map/impl#[`Gaps<'a, K, V>`][Iterator]next().(), Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#);
1440 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(gaps.nextrust-analyzer cargo rangemap 1.7.1 map/impl#[`Gaps<'a, K, V>`][Iterator]next().(), Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#);
1441 }
1442
1443 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
1444 fn item_ending_at_end_of_outer_rangerust-analyzer cargo rangemap 1.7.1 map/tests/item_ending_at_end_of_outer_range().() {
1445 let mut range_map: RangeMaprust-analyzer cargo rangemap 1.7.1 map/RangeMap#<u32, ()> = RangeMaprust-analyzer cargo rangemap 1.7.1 map/RangeMap#::newrust-analyzer cargo rangemap 1.7.1 map/impl#[`RangeMap<K, V>`]new().();
1446 // 0 1 2 3 4 5 6 7 8 9
1447 // ◌ ◌ ◌ ◌ ◌ ◌ ◌ ●-◌ ◌
1448 range_map.insertrust-analyzer cargo rangemap 1.7.1 map/impl#[`RangeMap<K, V>`]insert().(7..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#8, ());
1449 // 0 1 2 3 4 5 6 7 8 9
1450 // ◌ ◌ ◌ ◌ ◌ ◆-----◇ ◌
1451 let outer_range = 5..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#8;
1452 let mut gaps = range_map.gapsrust-analyzer cargo rangemap 1.7.1 map/impl#[`RangeMap<K, V>`]gaps().(&outer_range);
1453 // Should yield from the start of the outer range
1454 // up to the start of the stored item.
1455 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(gaps.nextrust-analyzer cargo rangemap 1.7.1 map/impl#[`Gaps<'a, K, V>`][Iterator]next().(), Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(5..7));
1456 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(gaps.nextrust-analyzer cargo rangemap 1.7.1 map/impl#[`Gaps<'a, K, V>`][Iterator]next().(), Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#);
1457 // Gaps iterator should be fused.
1458 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(gaps.nextrust-analyzer cargo rangemap 1.7.1 map/impl#[`Gaps<'a, K, V>`][Iterator]next().(), Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#);
1459 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(gaps.nextrust-analyzer cargo rangemap 1.7.1 map/impl#[`Gaps<'a, K, V>`][Iterator]next().(), Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#);
1460 }
1461
1462 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
1463 fn item_overlapping_end_of_outer_rangerust-analyzer cargo rangemap 1.7.1 map/tests/item_overlapping_end_of_outer_range().() {
1464 let mut range_map: RangeMaprust-analyzer cargo rangemap 1.7.1 map/RangeMap#<u32, ()> = RangeMaprust-analyzer cargo rangemap 1.7.1 map/RangeMap#::newrust-analyzer cargo rangemap 1.7.1 map/impl#[`RangeMap<K, V>`]new().();
1465 // 0 1 2 3 4 5 6 7 8 9
1466 // ◌ ◌ ◌ ◌ ●---◌ ◌ ◌ ◌
1467 range_map.insertrust-analyzer cargo rangemap 1.7.1 map/impl#[`RangeMap<K, V>`]insert().(4..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#6, ());
1468 // 0 1 2 3 4 5 6 7 8 9
1469 // ◌ ◌ ◆-----◇ ◌ ◌ ◌ ◌
1470 let outer_range = 2..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#5;
1471 let mut gaps = range_map.gapsrust-analyzer cargo rangemap 1.7.1 map/impl#[`RangeMap<K, V>`]gaps().(&outer_range);
1472 // Should yield from the start of the outer range
1473 // up to the start of the stored item.
1474 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(gaps.nextrust-analyzer cargo rangemap 1.7.1 map/impl#[`Gaps<'a, K, V>`][Iterator]next().(), Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(2..4));
1475 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(gaps.nextrust-analyzer cargo rangemap 1.7.1 map/impl#[`Gaps<'a, K, V>`][Iterator]next().(), Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#);
1476 // Gaps iterator should be fused.
1477 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(gaps.nextrust-analyzer cargo rangemap 1.7.1 map/impl#[`Gaps<'a, K, V>`][Iterator]next().(), Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#);
1478 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(gaps.nextrust-analyzer cargo rangemap 1.7.1 map/impl#[`Gaps<'a, K, V>`][Iterator]next().(), Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#);
1479 }
1480
1481 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
1482 fn item_touching_end_of_outer_rangerust-analyzer cargo rangemap 1.7.1 map/tests/item_touching_end_of_outer_range().() {
1483 let mut range_map: RangeMaprust-analyzer cargo rangemap 1.7.1 map/RangeMap#<u32, ()> = RangeMaprust-analyzer cargo rangemap 1.7.1 map/RangeMap#::newrust-analyzer cargo rangemap 1.7.1 map/impl#[`RangeMap<K, V>`]new().();
1484 // 0 1 2 3 4 5 6 7 8 9
1485 // ◌ ◌ ◌ ◌ ●-------◌ ◌
1486 range_map.insertrust-analyzer cargo rangemap 1.7.1 map/impl#[`RangeMap<K, V>`]insert().(4..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#8, ());
1487 // 0 1 2 3 4 5 6 7 8 9
1488 // ◌ ◆-----◇ ◌ ◌ ◌ ◌ ◌
1489 let outer_range = 1..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#4;
1490 let mut gaps = range_map.gapsrust-analyzer cargo rangemap 1.7.1 map/impl#[`RangeMap<K, V>`]gaps().(&outer_range);
1491 // Should yield the entire outer range.
1492 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(gaps.nextrust-analyzer cargo rangemap 1.7.1 map/impl#[`Gaps<'a, K, V>`][Iterator]next().(), Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(1..4));
1493 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(gaps.nextrust-analyzer cargo rangemap 1.7.1 map/impl#[`Gaps<'a, K, V>`][Iterator]next().(), Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#);
1494 // Gaps iterator should be fused.
1495 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(gaps.nextrust-analyzer cargo rangemap 1.7.1 map/impl#[`Gaps<'a, K, V>`][Iterator]next().(), Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#);
1496 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(gaps.nextrust-analyzer cargo rangemap 1.7.1 map/impl#[`Gaps<'a, K, V>`][Iterator]next().(), Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#);
1497 }
1498
1499 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
1500 fn item_after_outer_rangerust-analyzer cargo rangemap 1.7.1 map/tests/item_after_outer_range().() {
1501 let mut range_map: RangeMaprust-analyzer cargo rangemap 1.7.1 map/RangeMap#<u32, ()> = RangeMaprust-analyzer cargo rangemap 1.7.1 map/RangeMap#::newrust-analyzer cargo rangemap 1.7.1 map/impl#[`RangeMap<K, V>`]new().();
1502 // 0 1 2 3 4 5 6 7 8 9
1503 // ◌ ◌ ◌ ◌ ◌ ◌ ●---◌ ◌
1504 range_map.insertrust-analyzer cargo rangemap 1.7.1 map/impl#[`RangeMap<K, V>`]insert().(6..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#7, ());
1505 // 0 1 2 3 4 5 6 7 8 9
1506 // ◌ ◆-----◇ ◌ ◌ ◌ ◌ ◌
1507 let outer_range = 1..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#4;
1508 let mut gaps = range_map.gapsrust-analyzer cargo rangemap 1.7.1 map/impl#[`RangeMap<K, V>`]gaps().(&outer_range);
1509 // Should yield the entire outer range.
1510 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(gaps.nextrust-analyzer cargo rangemap 1.7.1 map/impl#[`Gaps<'a, K, V>`][Iterator]next().(), Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(1..4));
1511 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(gaps.nextrust-analyzer cargo rangemap 1.7.1 map/impl#[`Gaps<'a, K, V>`][Iterator]next().(), Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#);
1512 // Gaps iterator should be fused.
1513 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(gaps.nextrust-analyzer cargo rangemap 1.7.1 map/impl#[`Gaps<'a, K, V>`][Iterator]next().(), Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#);
1514 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(gaps.nextrust-analyzer cargo rangemap 1.7.1 map/impl#[`Gaps<'a, K, V>`][Iterator]next().(), Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#);
1515 }
1516
1517 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
1518 fn empty_outer_range_with_items_away_from_both_sidesrust-analyzer cargo rangemap 1.7.1 map/tests/empty_outer_range_with_items_away_from_both_sides().() {
1519 let mut range_map: RangeMaprust-analyzer cargo rangemap 1.7.1 map/RangeMap#<u32, ()> = RangeMaprust-analyzer cargo rangemap 1.7.1 map/RangeMap#::newrust-analyzer cargo rangemap 1.7.1 map/impl#[`RangeMap<K, V>`]new().();
1520 // 0 1 2 3 4 5 6 7 8 9
1521 // ◌ ◆---◇ ◌ ◌ ◌ ◌ ◌ ◌
1522 range_map.insertrust-analyzer cargo rangemap 1.7.1 map/impl#[`RangeMap<K, V>`]insert().(1..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#3, ());
1523 // 0 1 2 3 4 5 6 7 8 9
1524 // ◌ ◌ ◌ ◌ ◌ ◆---◇ ◌ ◌
1525 range_map.insertrust-analyzer cargo rangemap 1.7.1 map/impl#[`RangeMap<K, V>`]insert().(5..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#7, ());
1526 // 0 1 2 3 4 5 6 7 8 9
1527 // ◌ ◌ ◌ ◌ ◆ ◌ ◌ ◌ ◌ ◌
1528 let outer_range = 4..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#4;
1529 let mut gaps = range_map.gapsrust-analyzer cargo rangemap 1.7.1 map/impl#[`RangeMap<K, V>`]gaps().(&outer_range);
1530 // Should not yield any gaps, because a zero-width outer range covers no values.
1531 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(gaps.nextrust-analyzer cargo rangemap 1.7.1 map/impl#[`Gaps<'a, K, V>`][Iterator]next().(), Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#);
1532 // Gaps iterator should be fused.
1533 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(gaps.nextrust-analyzer cargo rangemap 1.7.1 map/impl#[`Gaps<'a, K, V>`][Iterator]next().(), Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#);
1534 }
1535
1536 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
1537 fn empty_outer_range_with_items_touching_both_sidesrust-analyzer cargo rangemap 1.7.1 map/tests/empty_outer_range_with_items_touching_both_sides().() {
1538 let mut range_map: RangeMaprust-analyzer cargo rangemap 1.7.1 map/RangeMap#<u32, ()> = RangeMaprust-analyzer cargo rangemap 1.7.1 map/RangeMap#::newrust-analyzer cargo rangemap 1.7.1 map/impl#[`RangeMap<K, V>`]new().();
1539 // 0 1 2 3 4 5 6 7 8 9
1540 // ◌ ◌ ◆---◇ ◌ ◌ ◌ ◌ ◌ ◌
1541 range_map.insertrust-analyzer cargo rangemap 1.7.1 map/impl#[`RangeMap<K, V>`]insert().(2..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#4, ());
1542 // 0 1 2 3 4 5 6 7 8 9
1543 // ◌ ◌ ◌ ◌ ◆---◇ ◌ ◌ ◌
1544 range_map.insertrust-analyzer cargo rangemap 1.7.1 map/impl#[`RangeMap<K, V>`]insert().(4..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#6, ());
1545 // 0 1 2 3 4 5 6 7 8 9
1546 // ◌ ◌ ◌ ◌ ◆ ◌ ◌ ◌ ◌ ◌
1547 let outer_range = 4..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#4;
1548 let mut gaps = range_map.gapsrust-analyzer cargo rangemap 1.7.1 map/impl#[`RangeMap<K, V>`]gaps().(&outer_range);
1549 // Should yield no gaps.
1550 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(gaps.nextrust-analyzer cargo rangemap 1.7.1 map/impl#[`Gaps<'a, K, V>`][Iterator]next().(), Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#);
1551 // Gaps iterator should be fused.
1552 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(gaps.nextrust-analyzer cargo rangemap 1.7.1 map/impl#[`Gaps<'a, K, V>`][Iterator]next().(), Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#);
1553 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(gaps.nextrust-analyzer cargo rangemap 1.7.1 map/impl#[`Gaps<'a, K, V>`][Iterator]next().(), Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#);
1554 }
1555
1556 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
1557 fn empty_outer_range_with_item_straddlingrust-analyzer cargo rangemap 1.7.1 map/tests/empty_outer_range_with_item_straddling().() {
1558 let mut range_map: RangeMaprust-analyzer cargo rangemap 1.7.1 map/RangeMap#<u32, ()> = RangeMaprust-analyzer cargo rangemap 1.7.1 map/RangeMap#::newrust-analyzer cargo rangemap 1.7.1 map/impl#[`RangeMap<K, V>`]new().();
1559 // 0 1 2 3 4 5 6 7 8 9
1560 // ◌ ◌ ◆-----◇ ◌ ◌ ◌ ◌ ◌
1561 range_map.insertrust-analyzer cargo rangemap 1.7.1 map/impl#[`RangeMap<K, V>`]insert().(2..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#5, ());
1562 // 0 1 2 3 4 5 6 7 8 9
1563 // ◌ ◌ ◌ ◌ ◆ ◌ ◌ ◌ ◌ ◌
1564 let outer_range = 4..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#4;
1565 let mut gaps = range_map.gapsrust-analyzer cargo rangemap 1.7.1 map/impl#[`RangeMap<K, V>`]gaps().(&outer_range);
1566 // Should yield no gaps.
1567 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(gaps.nextrust-analyzer cargo rangemap 1.7.1 map/impl#[`Gaps<'a, K, V>`][Iterator]next().(), Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#);
1568 // Gaps iterator should be fused.
1569 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(gaps.nextrust-analyzer cargo rangemap 1.7.1 map/impl#[`Gaps<'a, K, V>`][Iterator]next().(), Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#);
1570 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(gaps.nextrust-analyzer cargo rangemap 1.7.1 map/impl#[`Gaps<'a, K, V>`][Iterator]next().(), Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#);
1571 }
1572
1573 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
1574 fn no_empty_gapsrust-analyzer cargo rangemap 1.7.1 map/tests/no_empty_gaps().() {
1575 // Make two ranges different values so they don't
1576 // get coalesced.
1577 let mut range_map: RangeMaprust-analyzer cargo rangemap 1.7.1 map/RangeMap#<u32, bool> = RangeMaprust-analyzer cargo rangemap 1.7.1 map/RangeMap#::newrust-analyzer cargo rangemap 1.7.1 map/impl#[`RangeMap<K, V>`]new().();
1578 // 0 1 2 3 4 5 6 7 8 9
1579 // ◌ ◌ ◌ ◌ ●-◌ ◌ ◌ ◌ ◌
1580 range_map.insertrust-analyzer cargo rangemap 1.7.1 map/impl#[`RangeMap<K, V>`]insert().(4..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#5, true);
1581 // 0 1 2 3 4 5 6 7 8 9
1582 // ◌ ◌ ◌ ●-◌ ◌ ◌ ◌ ◌ ◌
1583 range_map.insertrust-analyzer cargo rangemap 1.7.1 map/impl#[`RangeMap<K, V>`]insert().(3..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#4, false);
1584 // 0 1 2 3 4 5 6 7 8 9
1585 // ◌ ◆-------------◇ ◌
1586 let outer_range = 1..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#8;
1587 let mut gaps = range_map.gapsrust-analyzer cargo rangemap 1.7.1 map/impl#[`RangeMap<K, V>`]gaps().(&outer_range);
1588 // Should yield gaps at start and end, but not between the
1589 // two touching items. (4 is covered, so there should be no gap.)
1590 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(gaps.nextrust-analyzer cargo rangemap 1.7.1 map/impl#[`Gaps<'a, K, V>`][Iterator]next().(), Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(1..3));
1591 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(gaps.nextrust-analyzer cargo rangemap 1.7.1 map/impl#[`Gaps<'a, K, V>`][Iterator]next().(), Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(5..8));
1592 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(gaps.nextrust-analyzer cargo rangemap 1.7.1 map/impl#[`Gaps<'a, K, V>`][Iterator]next().(), Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#);
1593 // Gaps iterator should be fused.
1594 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(gaps.nextrust-analyzer cargo rangemap 1.7.1 map/impl#[`Gaps<'a, K, V>`][Iterator]next().(), Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#);
1595 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(gaps.nextrust-analyzer cargo rangemap 1.7.1 map/impl#[`Gaps<'a, K, V>`][Iterator]next().(), Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#);
1596 }
1597
1598 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
1599 fn adjacent_small_itemsrust-analyzer cargo rangemap 1.7.1 map/tests/adjacent_small_items().() {
1600 // Items two items next to each other at the start, and at the end.
1601 let mut range_map: RangeMaprust-analyzer cargo rangemap 1.7.1 map/RangeMap#<u8, bool> = RangeMaprust-analyzer cargo rangemap 1.7.1 map/RangeMap#::newrust-analyzer cargo rangemap 1.7.1 map/impl#[`RangeMap<K, V>`]new().();
1602 range_map.insertrust-analyzer cargo rangemap 1.7.1 map/impl#[`RangeMap<K, V>`]insert().(0..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#1, false);
1603 range_map.insertrust-analyzer cargo rangemap 1.7.1 map/impl#[`RangeMap<K, V>`]insert().(1..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#2, true);
1604 range_map.insertrust-analyzer cargo rangemap 1.7.1 map/impl#[`RangeMap<K, V>`]insert().(253..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#254, false);
1605 range_map.insertrust-analyzer cargo rangemap 1.7.1 map/impl#[`RangeMap<K, V>`]insert().(254..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#255, true);
1606
1607 let outer_range = 0..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#255;
1608 let mut gaps = range_map.gapsrust-analyzer cargo rangemap 1.7.1 map/impl#[`RangeMap<K, V>`]gaps().(&outer_range);
1609 // Should yield one big gap in the middle.
1610 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(gaps.nextrust-analyzer cargo rangemap 1.7.1 map/impl#[`Gaps<'a, K, V>`][Iterator]next().(), Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(2..253));
1611 // Gaps iterator should be fused.
1612 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(gaps.nextrust-analyzer cargo rangemap 1.7.1 map/impl#[`Gaps<'a, K, V>`][Iterator]next().(), Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#);
1613 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(gaps.nextrust-analyzer cargo rangemap 1.7.1 map/impl#[`Gaps<'a, K, V>`][Iterator]next().(), Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#);
1614 }
1615
1616 // This test fails in v1.0.2
1617 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
1618 fn outer_range_lies_within_first_of_two_stored_rangesrust-analyzer cargo rangemap 1.7.1 map/tests/outer_range_lies_within_first_of_two_stored_ranges().() {
1619 let mut range_map: RangeMaprust-analyzer cargo rangemap 1.7.1 map/RangeMap#<u64, ()> = RangeMaprust-analyzer cargo rangemap 1.7.1 map/RangeMap#::newrust-analyzer cargo rangemap 1.7.1 map/impl#[`RangeMap<K, V>`]new().();
1620 // 0 1 2 3 4 5 6 7 8 9
1621 // ◆----------◇ ◌ ◌ ◌ ◌
1622 range_map.insertrust-analyzer cargo rangemap 1.7.1 map/impl#[`RangeMap<K, V>`]insert().(0..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#5, ());
1623 // 0 1 2 3 4 5 6 7 8 9
1624 // ◌ ◌ ◌ ◌◌ ◌ ◆---◇ ◌
1625 range_map.insertrust-analyzer cargo rangemap 1.7.1 map/impl#[`RangeMap<K, V>`]insert().(6..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#8, ());
1626 // 0 1 2 3 4 5 6 7 8 9
1627 // ◌ ◆--◇ ◌ ◌ ◌ ◌ ◌
1628 let outer_range: Rangerust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#<u64> = 1..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#3;
1629 let mut gaps = range_map.gapsrust-analyzer cargo rangemap 1.7.1 map/impl#[`RangeMap<K, V>`]gaps().(&outer_range);
1630 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(gaps.nextrust-analyzer cargo rangemap 1.7.1 map/impl#[`Gaps<'a, K, V>`][Iterator]next().(), Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#);
1631 }
1632
1633 // Overlapping tests
1634
1635 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
1636 fn overlapping_with_empty_maprust-analyzer cargo rangemap 1.7.1 map/tests/overlapping_with_empty_map().() {
1637 // 0 1 2 3 4 5 6 7 8 9
1638 // ◌ ◌ ◌ ◌ ◌ ◌ ◌ ◌ ◌ ◌
1639 let range_map: RangeMaprust-analyzer cargo rangemap 1.7.1 map/RangeMap#<u32, ()> = RangeMaprust-analyzer cargo rangemap 1.7.1 map/RangeMap#::newrust-analyzer cargo rangemap 1.7.1 map/impl#[`RangeMap<K, V>`]new().();
1640 // 0 1 2 3 4 5 6 7 8 9
1641 // ◌ ◆-------------◇ ◌
1642 let query_range = 1..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#8;
1643 let mut overlapping = range_map.overlappingrust-analyzer cargo rangemap 1.7.1 map/impl#[`RangeMap<K, V>`]overlapping().(&query_range);
1644 // Should not yield any items.
1645 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(overlapping.nextrust-analyzer cargo rangemap 1.7.1 map/impl#[`Overlapping<'a, K, V, R>`][Iterator]next().(), Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#);
1646 // Gaps iterator should be fused.
1647 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(overlapping.nextrust-analyzer cargo rangemap 1.7.1 map/impl#[`Overlapping<'a, K, V, R>`][Iterator]next().(), Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#);
1648 }
1649
1650 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
1651 fn overlapping_partial_edges_complete_middlerust-analyzer cargo rangemap 1.7.1 map/tests/overlapping_partial_edges_complete_middle().() {
1652 let mut range_map: RangeMaprust-analyzer cargo rangemap 1.7.1 map/RangeMap#<u32, ()> = RangeMaprust-analyzer cargo rangemap 1.7.1 map/RangeMap#::newrust-analyzer cargo rangemap 1.7.1 map/impl#[`RangeMap<K, V>`]new().();
1653
1654 // 0 1 2 3 4 5 6 7 8 9
1655 // ●---◌ ◌ ◌ ◌ ◌ ◌ ◌ ◌
1656 range_map.insertrust-analyzer cargo rangemap 1.7.1 map/impl#[`RangeMap<K, V>`]insert().(0..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#2, ());
1657 // 0 1 2 3 4 5 6 7 8 9
1658 // ◌ ◌ ◌ ●-◌ ◌ ◌ ◌ ◌ ◌
1659 range_map.insertrust-analyzer cargo rangemap 1.7.1 map/impl#[`RangeMap<K, V>`]insert().(3..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#4, ());
1660 // 0 1 2 3 4 5 6 7 8 9
1661 // ◌ ◌ ◌ ◌ ◌ ●---◌ ◌ ◌
1662 range_map.insertrust-analyzer cargo rangemap 1.7.1 map/impl#[`RangeMap<K, V>`]insert().(5..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#7, ());
1663
1664 // 0 1 2 3 4 5 6 7 8 9
1665 // ◌ ◆---------◇ ◌ ◌ ◌
1666 let query_range = 1..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#6;
1667
1668 let mut overlapping = range_map.overlappingrust-analyzer cargo rangemap 1.7.1 map/impl#[`RangeMap<K, V>`]overlapping().(&query_range);
1669
1670 // Should yield partially overlapped range at start.
1671 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(overlapping.nextrust-analyzer cargo rangemap 1.7.1 map/impl#[`Overlapping<'a, K, V, R>`][Iterator]next().(), Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#((&(0..2), &())));
1672 // Should yield completely overlapped range in middle.
1673 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(overlapping.nextrust-analyzer cargo rangemap 1.7.1 map/impl#[`Overlapping<'a, K, V, R>`][Iterator]next().(), Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#((&(3..4), &())));
1674 // Should yield partially overlapped range at end.
1675 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(overlapping.nextrust-analyzer cargo rangemap 1.7.1 map/impl#[`Overlapping<'a, K, V, R>`][Iterator]next().(), Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#((&(5..7), &())));
1676 // Gaps iterator should be fused.
1677 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(overlapping.nextrust-analyzer cargo rangemap 1.7.1 map/impl#[`Overlapping<'a, K, V, R>`][Iterator]next().(), Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#);
1678 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(overlapping.nextrust-analyzer cargo rangemap 1.7.1 map/impl#[`Overlapping<'a, K, V, R>`][Iterator]next().(), Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#);
1679 }
1680
1681 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
1682 fn overlapping_non_overlapping_edges_complete_middlerust-analyzer cargo rangemap 1.7.1 map/tests/overlapping_non_overlapping_edges_complete_middle().() {
1683 let mut range_map: RangeMaprust-analyzer cargo rangemap 1.7.1 map/RangeMap#<u32, ()> = RangeMaprust-analyzer cargo rangemap 1.7.1 map/RangeMap#::newrust-analyzer cargo rangemap 1.7.1 map/impl#[`RangeMap<K, V>`]new().();
1684
1685 // 0 1 2 3 4 5 6 7 8 9
1686 // ●---◌ ◌ ◌ ◌ ◌ ◌ ◌ ◌
1687 range_map.insertrust-analyzer cargo rangemap 1.7.1 map/impl#[`RangeMap<K, V>`]insert().(0..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#2, ());
1688 // 0 1 2 3 4 5 6 7 8 9
1689 // ◌ ◌ ◌ ●-◌ ◌ ◌ ◌ ◌ ◌
1690 range_map.insertrust-analyzer cargo rangemap 1.7.1 map/impl#[`RangeMap<K, V>`]insert().(3..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#4, ());
1691 // 0 1 2 3 4 5 6 7 8 9
1692 // ◌ ◌ ◌ ◌ ◌ ●---◌ ◌ ◌
1693 range_map.insertrust-analyzer cargo rangemap 1.7.1 map/impl#[`RangeMap<K, V>`]insert().(5..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#7, ());
1694
1695 // 0 1 2 3 4 5 6 7 8 9
1696 // ◌ ◌ ◆-----◇ ◌ ◌ ◌ ◌
1697 let query_range = 2..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#5;
1698
1699 let mut overlapping = range_map.overlappingrust-analyzer cargo rangemap 1.7.1 map/impl#[`RangeMap<K, V>`]overlapping().(&query_range);
1700
1701 // Should only yield the completely overlapped range in middle.
1702 // (Not the ranges that are touched by not covered to either side.)
1703 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(overlapping.nextrust-analyzer cargo rangemap 1.7.1 map/impl#[`Overlapping<'a, K, V, R>`][Iterator]next().(), Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#((&(3..4), &())));
1704 // Gaps iterator should be fused.
1705 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(overlapping.nextrust-analyzer cargo rangemap 1.7.1 map/impl#[`Overlapping<'a, K, V, R>`][Iterator]next().(), Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#);
1706 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(overlapping.nextrust-analyzer cargo rangemap 1.7.1 map/impl#[`Overlapping<'a, K, V, R>`][Iterator]next().(), Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#);
1707 }
1708
1709 ///
1710 /// impl Debug
1711 ///
1712
1713 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
1714 fn map_debug_repr_looks_rightrust-analyzer cargo rangemap 1.7.1 map/tests/map_debug_repr_looks_right().() {
1715 let mut map: RangeMaprust-analyzer cargo rangemap 1.7.1 map/RangeMap#<u32, ()> = RangeMaprust-analyzer cargo rangemap 1.7.1 map/RangeMap#::newrust-analyzer cargo rangemap 1.7.1 map/impl#[`RangeMap<K, V>`]new().();
1716
1717 // Empty
1718 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!!("{:?}", map), "{}");
1719
1720 // One entry
1721 map.insertrust-analyzer cargo rangemap 1.7.1 map/impl#[`RangeMap<K, V>`]insert().(2..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#5, ());
1722 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!!("{:?}", map), "{2..5: ()}");
1723
1724 // Many entries
1725 map.insertrust-analyzer cargo rangemap 1.7.1 map/impl#[`RangeMap<K, V>`]insert().(6..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#7, ());
1726 map.insertrust-analyzer cargo rangemap 1.7.1 map/impl#[`RangeMap<K, V>`]insert().(8..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#9, ());
1727 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!!("{:?}", map), "{2..5: (), 6..7: (), 8..9: ()}");
1728 }
1729
1730 // impl Default where T: ?Default
1731
1732 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
1733 fn always_defaultrust-analyzer cargo rangemap 1.7.1 map/tests/always_default().() {
1734 struct NoDefaultrust-analyzer cargo rangemap 1.7.1 map/tests/NoDefault#;
1735 RangeMaprust-analyzer cargo rangemap 1.7.1 map/RangeMap#::<NoDefaultrust-analyzer cargo rangemap 1.7.1 map/tests/NoDefault#, NoDefaultrust-analyzer cargo rangemap 1.7.1 map/tests/NoDefault#>::defaultrust-analyzer cargo rangemap 1.7.1 map/impl#[`RangeMap<K, V>`][Default]default().();
1736 }
1737
1738 // Iterator Tests
1739
1740 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
1741 fn into_iter_matches_iterrust-analyzer cargo rangemap 1.7.1 map/tests/into_iter_matches_iter().() {
1742 // Just use vec since that's the same implementation we'd expect
1743 let mut range_map: RangeMaprust-analyzer cargo rangemap 1.7.1 map/RangeMap#<u32, bool> = RangeMaprust-analyzer cargo rangemap 1.7.1 map/RangeMap#::newrust-analyzer cargo rangemap 1.7.1 map/impl#[`RangeMap<K, V>`]new().();
1744 range_map.insertrust-analyzer cargo rangemap 1.7.1 map/impl#[`RangeMap<K, V>`]insert().(1..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#3, false);
1745 range_map.insertrust-analyzer cargo rangemap 1.7.1 map/impl#[`RangeMap<K, V>`]insert().(3..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#5, true);
1746
1747 let cloned = range_map.to_vecrust-analyzer cargo rangemap 1.7.1 map/tests/impl#[`RangeMap<K, V>`][`RangeMapExt<K, V>`]to_vec().();
1748 let consumed = range_map.into_iterrust-analyzer cargo rangemap 1.7.1 map/impl#[`RangeMap<K, V>`][IntoIterator]into_iter().().collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().::<Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<_>>();
1749
1750 // Correct value
1751 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(cloned, vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![(1..3, false), (3..5, true)]);
1752
1753 // Equality
1754 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(cloned, consumed);
1755 }
1756
1757 // Equality
1758 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
1759 fn eqrust-analyzer cargo rangemap 1.7.1 map/tests/eq().() {
1760 let mut a: RangeMaprust-analyzer cargo rangemap 1.7.1 map/RangeMap#<u32, bool> = RangeMaprust-analyzer cargo rangemap 1.7.1 map/RangeMap#::newrust-analyzer cargo rangemap 1.7.1 map/impl#[`RangeMap<K, V>`]new().();
1761 a.insertrust-analyzer cargo rangemap 1.7.1 map/impl#[`RangeMap<K, V>`]insert().(1..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#3, false);
1762
1763 let mut b: RangeMaprust-analyzer cargo rangemap 1.7.1 map/RangeMap#<u32, bool> = RangeMaprust-analyzer cargo rangemap 1.7.1 map/RangeMap#::newrust-analyzer cargo rangemap 1.7.1 map/impl#[`RangeMap<K, V>`]new().();
1764 b.insertrust-analyzer cargo rangemap 1.7.1 map/impl#[`RangeMap<K, V>`]insert().(1..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#4, false);
1765
1766 let mut c: RangeMaprust-analyzer cargo rangemap 1.7.1 map/RangeMap#<u32, bool> = RangeMaprust-analyzer cargo rangemap 1.7.1 map/RangeMap#::newrust-analyzer cargo rangemap 1.7.1 map/impl#[`RangeMap<K, V>`]new().();
1767 c.insertrust-analyzer cargo rangemap 1.7.1 map/impl#[`RangeMap<K, V>`]insert().(1..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#3, false);
1768
1769 assert_nerust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_ne!!(a, b);
1770 assert_nerust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_ne!!(b, a);
1771
1772 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(a, c);
1773 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(c, a);
1774 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(a, a);
1775 }
1776
1777 // Ord
1778 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
1779 fn partial_ordrust-analyzer cargo rangemap 1.7.1 map/tests/partial_ord().() {
1780 let mut a: RangeMaprust-analyzer cargo rangemap 1.7.1 map/RangeMap#<u32, bool> = RangeMaprust-analyzer cargo rangemap 1.7.1 map/RangeMap#::newrust-analyzer cargo rangemap 1.7.1 map/impl#[`RangeMap<K, V>`]new().();
1781 a.insertrust-analyzer cargo rangemap 1.7.1 map/impl#[`RangeMap<K, V>`]insert().(1..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#3, false);
1782
1783 let mut b: RangeMaprust-analyzer cargo rangemap 1.7.1 map/RangeMap#<u32, bool> = RangeMaprust-analyzer cargo rangemap 1.7.1 map/RangeMap#::newrust-analyzer cargo rangemap 1.7.1 map/impl#[`RangeMap<K, V>`]new().();
1784 b.insertrust-analyzer cargo rangemap 1.7.1 map/impl#[`RangeMap<K, V>`]insert().(1..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#4, false);
1785
1786 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(a.partial_cmprust-analyzer cargo rangemap 1.7.1 map/impl#[`RangeMap<K, V>`][`PartialOrd<Self>`]partial_cmp().(&a), Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(Orderingrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Ordering#::Equalrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Ordering#Equal#));
1787
1788 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(a.partial_cmprust-analyzer cargo rangemap 1.7.1 map/impl#[`RangeMap<K, V>`][`PartialOrd<Self>`]partial_cmp().(&b), Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(Orderingrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Ordering#::Lessrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Ordering#Less#));
1789 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(b.partial_cmprust-analyzer cargo rangemap 1.7.1 map/impl#[`RangeMap<K, V>`][`PartialOrd<Self>`]partial_cmp().(&a), Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(Orderingrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Ordering#::Greaterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Ordering#Greater#));
1790 }
1791
1792 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
1793 fn ordrust-analyzer cargo rangemap 1.7.1 map/tests/ord().() {
1794 let mut a: RangeMaprust-analyzer cargo rangemap 1.7.1 map/RangeMap#<u32, bool> = RangeMaprust-analyzer cargo rangemap 1.7.1 map/RangeMap#::newrust-analyzer cargo rangemap 1.7.1 map/impl#[`RangeMap<K, V>`]new().();
1795 a.insertrust-analyzer cargo rangemap 1.7.1 map/impl#[`RangeMap<K, V>`]insert().(1..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#3, false);
1796
1797 let mut b: RangeMaprust-analyzer cargo rangemap 1.7.1 map/RangeMap#<u32, bool> = RangeMaprust-analyzer cargo rangemap 1.7.1 map/RangeMap#::newrust-analyzer cargo rangemap 1.7.1 map/impl#[`RangeMap<K, V>`]new().();
1798 b.insertrust-analyzer cargo rangemap 1.7.1 map/impl#[`RangeMap<K, V>`]insert().(1..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#4, false);
1799
1800 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(a.cmprust-analyzer cargo rangemap 1.7.1 map/impl#[`RangeMap<K, V>`][Ord]cmp().(&a), Orderingrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Ordering#::Equalrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Ordering#Equal#);
1801
1802 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(a.cmprust-analyzer cargo rangemap 1.7.1 map/impl#[`RangeMap<K, V>`][Ord]cmp().(&b), Orderingrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Ordering#::Lessrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Ordering#Less#);
1803 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(b.cmprust-analyzer cargo rangemap 1.7.1 map/impl#[`RangeMap<K, V>`][Ord]cmp().(&a), Orderingrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Ordering#::Greaterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Ordering#Greater#);
1804 }
1805
1806 // impl Serialize
1807
1808 #[cfg(feature = "serde1")]
1809 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
1810 fn serializationrust-analyzer cargo rangemap 1.7.1 map/tests/serialization().() {
1811 let mut range_map: RangeMaprust-analyzer cargo rangemap 1.7.1 map/RangeMap#<u32, bool> = RangeMaprust-analyzer cargo rangemap 1.7.1 map/RangeMap#::newrust-analyzer cargo rangemap 1.7.1 map/impl#[`RangeMap<K, V>`]new().();
1812 // 0 1 2 3 4 5 6 7 8 9
1813 // ◌ ◆---◇ ◌ ◌ ◌ ◌ ◌ ◌
1814 range_map.insertrust-analyzer cargo rangemap 1.7.1 map/impl#[`RangeMap<K, V>`]insert().(1..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#3, false);
1815 // 0 1 2 3 4 5 6 7 8 9
1816 // ◌ ◌ ◌ ◌ ◌ ◆---◇ ◌ ◌
1817 range_map.insertrust-analyzer cargo rangemap 1.7.1 map/impl#[`RangeMap<K, V>`]insert().(5..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#7, true);
1818 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_map).expectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]expect().("Failed to serialize");
1819 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(output, "[[[1,3],false],[[5,7],true]]");
1820 }
1821
1822 // impl Deserialize
1823
1824 #[cfg(feature = "serde1")]
1825 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
1826 fn deserializationrust-analyzer cargo rangemap 1.7.1 map/tests/deserialization().() {
1827 let input = "[[[1,3],false],[[5,7],true]]";
1828 let range_map: RangeMaprust-analyzer cargo rangemap 1.7.1 map/RangeMap#<u32, bool> =
1829 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");
1830 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_map).expectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]expect().("Failed to re-serialize");
1831 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(reserialized, input);
1832 }
1833
1834 // const fn
1835
1836 #[cfg(feature = "const_fn")]
1837 const _MAPrust-analyzer cargo rangemap 1.7.1 map/tests/_MAP.: RangeMaprust-analyzer cargo rangemap 1.7.1 map/RangeMap#<u32, bool> = RangeMaprust-analyzer cargo rangemap 1.7.1 map/RangeMap#::newrust-analyzer cargo rangemap 1.7.1 map/impl#[`RangeMap<K, V>`]new().();
1838
1839 #[cfg(feature = "quickcheck")]
1840 quickcheckrust-analyzer cargo quickcheck 1.0.3 crate/::quickcheckrust-analyzer cargo quickcheck 1.0.3 quickcheck!! {
1841 fn proprust-analyzer cargo rangemap 1.7.1 map/tests/prop().(xs: RangeMaprust-analyzer cargo rangemap 1.7.1 map/RangeMap#<usize, usize>) -> bool {
1842 xs == xs
1843 }
1844 }
1845 }