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