| 1 | // Wrappers to allow storing (and sorting/searching) |
| 2 | // ranges as the keys of a `BTreeMap`. |
| 3 | // |
| 4 | // This wraps the range in two layers: one that lets us |
| 5 | // order ranges by their start (`RangeStartWrapper`), |
| 6 | // and then within that, one that lets us order them by |
| 7 | // their end (`RangeEndWrapper`). Ordinarily we'll use |
| 8 | // the former, but there are a couple of cases where we |
| 9 | // want to be able to do the latter for performance/convenience. |
| 10 | // |
| 11 | // This is made possible by a sneaky `Borrow` implementation |
| 12 | // which skirts the law about the borrowed representation |
| 13 | // having identical implementations of `Ord` etc., but shouldn't |
| 14 | // be a problem in practice because users of the crate can't |
| 15 | // access these special wrappers, and we are careful to uphold |
| 16 | // invariants that prevent observing any states where the |
| 17 | // differing implementations would produce different results. |
| 18 | // |
| 19 | // Specifically, we maintain the invariants |
| 20 | // that the order of range starts is the same as the order |
| 21 | // of range ends, and that no two stored ranges have the |
| 22 | // same start or end as each other. |
| 23 | // |
| 24 | // NOTE: Be very careful not to accidentally use these |
| 25 | // if you really do want to compare equality of the |
| 26 | // inner range! |
| 27 | |
| 28 | 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#; |
| 29 | 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/::{Derefrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/Deref#, Rangerust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#, RangeInclusiverust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/RangeInclusive#}; |
| 30 | |
| 31 | // |
| 32 | // Range start wrapper |
| 33 | // |
| 34 | |
| 35 | #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/macros/Debug:, Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone:)] |
| 36 | pub struct RangeStartWrapperrust-analyzer cargo rangemap 1.7.1 range_wrapper/RangeStartWrapper#<T> { |
| 37 | pub end_wrapperrust-analyzer cargo rangemap 1.7.1 range_wrapper/RangeStartWrapper#end_wrapper.: RangeEndWrapperrust-analyzer cargo rangemap 1.7.1 range_wrapper/RangeEndWrapper#<T>, |
| 38 | } |
| 39 | |
| 40 | impl<T> RangeStartWrapperrust-analyzer cargo rangemap 1.7.1 range_wrapper/RangeStartWrapper#<T> { |
| 41 | pub fn newrust-analyzer cargo rangemap 1.7.1 range_wrapper/impl#[`RangeStartWrapper<T>`]new().(range: Rangerust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#<T>) -> RangeStartWrapperrust-analyzer cargo rangemap 1.7.1 range_wrapper/RangeStartWrapper#<T> { |
| 42 | RangeStartWrapperrust-analyzer cargo rangemap 1.7.1 range_wrapper/RangeStartWrapper# { |
| 43 | end_wrapperrust-analyzer cargo rangemap 1.7.1 range_wrapper/RangeStartWrapper#end_wrapper.: RangeEndWrapperrust-analyzer cargo rangemap 1.7.1 range_wrapper/RangeEndWrapper#::newrust-analyzer cargo rangemap 1.7.1 range_wrapper/impl#[`RangeEndWrapper<T>`]new().(range), |
| 44 | } |
| 45 | } |
| 46 | } |
| 47 | |
| 48 | impl<T> PartialEqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq# for RangeStartWrapperrust-analyzer cargo rangemap 1.7.1 range_wrapper/RangeStartWrapper#<T> |
| 49 | where |
| 50 | T: PartialEqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq#, |
| 51 | { |
| 52 | fn eqrust-analyzer cargo rangemap 1.7.1 range_wrapper/impl#[`RangeStartWrapper<T>`][`PartialEq<Self>`]eq().(&self, other: &RangeStartWrapperrust-analyzer cargo rangemap 1.7.1 range_wrapper/RangeStartWrapper#<T>) -> bool { |
| 53 | self.startrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#start. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq#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().other.startrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#start. |
| 54 | } |
| 55 | } |
| 56 | |
| 57 | impl<T> Eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Eq# for RangeStartWrapperrust-analyzer cargo rangemap 1.7.1 range_wrapper/RangeStartWrapper#<T> where T: Eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Eq# {} |
| 58 | |
| 59 | impl<T> Ordrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Ord# for RangeStartWrapperrust-analyzer cargo rangemap 1.7.1 range_wrapper/RangeStartWrapper#<T> |
| 60 | where |
| 61 | T: Ordrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Ord#, |
| 62 | { |
| 63 | fn cmprust-analyzer cargo rangemap 1.7.1 range_wrapper/impl#[`RangeStartWrapper<T>`][Ord]cmp().(&self, other: &RangeStartWrapperrust-analyzer cargo rangemap 1.7.1 range_wrapper/RangeStartWrapper#<T>) -> Orderingrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Ordering# { |
| 64 | self.startrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#start..cmprust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Ord#cmp().(&other.startrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#start.) |
| 65 | } |
| 66 | } |
| 67 | |
| 68 | impl<T> PartialOrdrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialOrd# for RangeStartWrapperrust-analyzer cargo rangemap 1.7.1 range_wrapper/RangeStartWrapper#<T> |
| 69 | where |
| 70 | T: PartialOrdrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialOrd#, |
| 71 | { |
| 72 | fn partial_cmprust-analyzer cargo rangemap 1.7.1 range_wrapper/impl#[`RangeStartWrapper<T>`][`PartialOrd<Self>`]partial_cmp().(&self, other: &RangeStartWrapperrust-analyzer cargo rangemap 1.7.1 range_wrapper/RangeStartWrapper#<T>) -> 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#> { |
| 73 | self.startrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#start..partial_cmprust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialOrd#partial_cmp().(&other.startrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#start.) |
| 74 | } |
| 75 | } |
| 76 | |
| 77 | impl<T> 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#<RangeEndWrapperrust-analyzer cargo rangemap 1.7.1 range_wrapper/RangeEndWrapper#<T>> for RangeStartWrapperrust-analyzer cargo rangemap 1.7.1 range_wrapper/RangeStartWrapper#<T> { |
| 78 | fn borrowrust-analyzer cargo rangemap 1.7.1 range_wrapper/impl#[`RangeStartWrapper<T>`][`Borrow<RangeEndWrapper<T>>`]borrow().(&self) -> &RangeEndWrapperrust-analyzer cargo rangemap 1.7.1 range_wrapper/RangeEndWrapper#<T> { |
| 79 | &self.end_wrapperrust-analyzer cargo rangemap 1.7.1 range_wrapper/RangeStartWrapper#end_wrapper. |
| 80 | } |
| 81 | } |
| 82 | |
| 83 | // Avoid the need to tediously plumb through the layers of wrapper structs |
| 84 | // when you're just trying to access members of the inner range itself. |
| 85 | impl<T> Derefrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/Deref# for RangeStartWrapperrust-analyzer cargo rangemap 1.7.1 range_wrapper/RangeStartWrapper#<T> { |
| 86 | type Targetrust-analyzer cargo rangemap 1.7.1 range_wrapper/impl#[`RangeStartWrapper<T>`][Deref]Target# = RangeEndWrapperrust-analyzer cargo rangemap 1.7.1 range_wrapper/RangeEndWrapper#<T>; |
| 87 | |
| 88 | fn derefrust-analyzer cargo rangemap 1.7.1 range_wrapper/impl#[`RangeStartWrapper<T>`][Deref]deref().(&self) -> &Selfrust-analyzer cargo rangemap 1.7.1 range_wrapper/impl#[`RangeStartWrapper<T>`][Deref]::Targetrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/Deref#Target# { |
| 89 | &self.end_wrapperrust-analyzer cargo rangemap 1.7.1 range_wrapper/RangeStartWrapper#end_wrapper. |
| 90 | } |
| 91 | } |
| 92 | |
| 93 | // |
| 94 | // Range end wrapper |
| 95 | // |
| 96 | |
| 97 | #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/macros/Debug:, Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone:)] |
| 98 | pub struct RangeEndWrapperrust-analyzer cargo rangemap 1.7.1 range_wrapper/RangeEndWrapper#<T> { |
| 99 | pub rangerust-analyzer cargo rangemap 1.7.1 range_wrapper/RangeEndWrapper#range.: Rangerust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#<T>, |
| 100 | } |
| 101 | |
| 102 | impl<T> RangeEndWrapperrust-analyzer cargo rangemap 1.7.1 range_wrapper/RangeEndWrapper#<T> { |
| 103 | pub fn newrust-analyzer cargo rangemap 1.7.1 range_wrapper/impl#[`RangeEndWrapper<T>`]new().(range: Rangerust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#<T>) -> RangeEndWrapperrust-analyzer cargo rangemap 1.7.1 range_wrapper/RangeEndWrapper#<T> { |
| 104 | RangeEndWrapperrust-analyzer cargo rangemap 1.7.1 range_wrapper/RangeEndWrapper# { rangerust-analyzer cargo rangemap 1.7.1 range_wrapper/RangeEndWrapper#range. } |
| 105 | } |
| 106 | } |
| 107 | |
| 108 | impl<T> PartialEqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq# for RangeEndWrapperrust-analyzer cargo rangemap 1.7.1 range_wrapper/RangeEndWrapper#<T> |
| 109 | where |
| 110 | T: PartialEqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq#, |
| 111 | { |
| 112 | fn eqrust-analyzer cargo rangemap 1.7.1 range_wrapper/impl#[`RangeEndWrapper<T>`][`PartialEq<Self>`]eq().(&self, other: &RangeEndWrapperrust-analyzer cargo rangemap 1.7.1 range_wrapper/RangeEndWrapper#<T>) -> bool { |
| 113 | self.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/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().other.endrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#end. |
| 114 | } |
| 115 | } |
| 116 | |
| 117 | impl<T> Eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Eq# for RangeEndWrapperrust-analyzer cargo rangemap 1.7.1 range_wrapper/RangeEndWrapper#<T> where T: Eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Eq# {} |
| 118 | |
| 119 | impl<T> Ordrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Ord# for RangeEndWrapperrust-analyzer cargo rangemap 1.7.1 range_wrapper/RangeEndWrapper#<T> |
| 120 | where |
| 121 | T: Ordrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Ord#, |
| 122 | { |
| 123 | fn cmprust-analyzer cargo rangemap 1.7.1 range_wrapper/impl#[`RangeEndWrapper<T>`][Ord]cmp().(&self, other: &RangeEndWrapperrust-analyzer cargo rangemap 1.7.1 range_wrapper/RangeEndWrapper#<T>) -> Orderingrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Ordering# { |
| 124 | self.endrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#end..cmprust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Ord#cmp().(&other.endrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#end.) |
| 125 | } |
| 126 | } |
| 127 | |
| 128 | impl<T> PartialOrdrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialOrd# for RangeEndWrapperrust-analyzer cargo rangemap 1.7.1 range_wrapper/RangeEndWrapper#<T> |
| 129 | where |
| 130 | T: PartialOrdrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialOrd#, |
| 131 | { |
| 132 | fn partial_cmprust-analyzer cargo rangemap 1.7.1 range_wrapper/impl#[`RangeEndWrapper<T>`][`PartialOrd<Self>`]partial_cmp().(&self, other: &RangeEndWrapperrust-analyzer cargo rangemap 1.7.1 range_wrapper/RangeEndWrapper#<T>) -> 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#> { |
| 133 | self.endrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#end..partial_cmprust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialOrd#partial_cmp().(&other.endrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#end.) |
| 134 | } |
| 135 | } |
| 136 | |
| 137 | // Avoid the need to tediously plumb through the layers of wrapper structs |
| 138 | // when you're just trying to access members of the inner range itself. |
| 139 | impl<T> Derefrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/Deref# for RangeEndWrapperrust-analyzer cargo rangemap 1.7.1 range_wrapper/RangeEndWrapper#<T> { |
| 140 | type Targetrust-analyzer cargo rangemap 1.7.1 range_wrapper/impl#[`RangeEndWrapper<T>`][Deref]Target# = Rangerust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#<T>; |
| 141 | |
| 142 | fn derefrust-analyzer cargo rangemap 1.7.1 range_wrapper/impl#[`RangeEndWrapper<T>`][Deref]deref().(&self) -> &Selfrust-analyzer cargo rangemap 1.7.1 range_wrapper/impl#[`RangeEndWrapper<T>`][Deref]::Targetrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/Deref#Target# { |
| 143 | &self.rangerust-analyzer cargo rangemap 1.7.1 range_wrapper/RangeEndWrapper#range. |
| 144 | } |
| 145 | } |
| 146 | |
| 147 | // |
| 148 | // RangeInclusive start wrapper |
| 149 | // |
| 150 | |
| 151 | #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Eq:, Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/macros/Debug:, Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone:)] |
| 152 | pub struct RangeInclusiveStartWrapperrust-analyzer cargo rangemap 1.7.1 range_wrapper/RangeInclusiveStartWrapper#<T> { |
| 153 | pub end_wrapperrust-analyzer cargo rangemap 1.7.1 range_wrapper/RangeInclusiveStartWrapper#end_wrapper.: RangeInclusiveEndWrapperrust-analyzer cargo rangemap 1.7.1 range_wrapper/RangeInclusiveEndWrapper#<T>, |
| 154 | } |
| 155 | |
| 156 | impl<T> RangeInclusiveStartWrapperrust-analyzer cargo rangemap 1.7.1 range_wrapper/RangeInclusiveStartWrapper#<T> { |
| 157 | pub fn newrust-analyzer cargo rangemap 1.7.1 range_wrapper/impl#[`RangeInclusiveStartWrapper<T>`]new().(range: RangeInclusiverust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/RangeInclusive#<T>) -> RangeInclusiveStartWrapperrust-analyzer cargo rangemap 1.7.1 range_wrapper/RangeInclusiveStartWrapper#<T> { |
| 158 | RangeInclusiveStartWrapperrust-analyzer cargo rangemap 1.7.1 range_wrapper/RangeInclusiveStartWrapper# { |
| 159 | end_wrapperrust-analyzer cargo rangemap 1.7.1 range_wrapper/RangeInclusiveStartWrapper#end_wrapper.: RangeInclusiveEndWrapperrust-analyzer cargo rangemap 1.7.1 range_wrapper/RangeInclusiveEndWrapper#::newrust-analyzer cargo rangemap 1.7.1 range_wrapper/impl#[`RangeInclusiveEndWrapper<T>`]new().(range), |
| 160 | } |
| 161 | } |
| 162 | } |
| 163 | |
| 164 | impl<T> PartialEqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq# for RangeInclusiveStartWrapperrust-analyzer cargo rangemap 1.7.1 range_wrapper/RangeInclusiveStartWrapper#<T> |
| 165 | where |
| 166 | T: PartialEqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq#, |
| 167 | { |
| 168 | fn eqrust-analyzer cargo rangemap 1.7.1 range_wrapper/impl#[`RangeInclusiveStartWrapper<T>`][`PartialEq<Self>`]eq().(&self, other: &RangeInclusiveStartWrapperrust-analyzer cargo rangemap 1.7.1 range_wrapper/RangeInclusiveStartWrapper#<T>) -> bool { |
| 169 | self.startrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/impl#[`RangeInclusive<Idx>`]start().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialEq<&B>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialEq<&B>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialEq<&B>`]eq().other.startrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/impl#[`RangeInclusive<Idx>`]start().() |
| 170 | } |
| 171 | } |
| 172 | |
| 173 | impl<T> Ordrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Ord# for RangeInclusiveStartWrapperrust-analyzer cargo rangemap 1.7.1 range_wrapper/RangeInclusiveStartWrapper#<T> |
| 174 | where |
| 175 | T: Ordrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Ord#, |
| 176 | { |
| 177 | fn cmprust-analyzer cargo rangemap 1.7.1 range_wrapper/impl#[`RangeInclusiveStartWrapper<T>`][Ord]cmp().(&self, other: &RangeInclusiveStartWrapperrust-analyzer cargo rangemap 1.7.1 range_wrapper/RangeInclusiveStartWrapper#<T>) -> Orderingrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Ordering# { |
| 178 | self.startrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/impl#[`RangeInclusive<Idx>`]start().().cmprust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Ord#cmp().(other.startrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/impl#[`RangeInclusive<Idx>`]start().()) |
| 179 | } |
| 180 | } |
| 181 | |
| 182 | impl<T> PartialOrdrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialOrd# for RangeInclusiveStartWrapperrust-analyzer cargo rangemap 1.7.1 range_wrapper/RangeInclusiveStartWrapper#<T> |
| 183 | where |
| 184 | T: PartialOrdrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialOrd#, |
| 185 | { |
| 186 | fn partial_cmprust-analyzer cargo rangemap 1.7.1 range_wrapper/impl#[`RangeInclusiveStartWrapper<T>`][`PartialOrd<Self>`]partial_cmp().(&self, other: &RangeInclusiveStartWrapperrust-analyzer cargo rangemap 1.7.1 range_wrapper/RangeInclusiveStartWrapper#<T>) -> 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#> { |
| 187 | self.startrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/impl#[`RangeInclusive<Idx>`]start().().partial_cmprust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialOrd#partial_cmp().(other.startrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/impl#[`RangeInclusive<Idx>`]start().()) |
| 188 | } |
| 189 | } |
| 190 | |
| 191 | impl<T> 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#<RangeInclusiveEndWrapperrust-analyzer cargo rangemap 1.7.1 range_wrapper/RangeInclusiveEndWrapper#<T>> for RangeInclusiveStartWrapperrust-analyzer cargo rangemap 1.7.1 range_wrapper/RangeInclusiveStartWrapper#<T> { |
| 192 | fn borrowrust-analyzer cargo rangemap 1.7.1 range_wrapper/impl#[`RangeInclusiveStartWrapper<T>`][`Borrow<RangeInclusiveEndWrapper<T>>`]borrow().(&self) -> &RangeInclusiveEndWrapperrust-analyzer cargo rangemap 1.7.1 range_wrapper/RangeInclusiveEndWrapper#<T> { |
| 193 | &self.end_wrapperrust-analyzer cargo rangemap 1.7.1 range_wrapper/RangeInclusiveStartWrapper#end_wrapper. |
| 194 | } |
| 195 | } |
| 196 | |
| 197 | // Avoid the need to tediously plumb through the layers of wrapper structs |
| 198 | // when you're just trying to access members of the inner range itself. |
| 199 | impl<T> Derefrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/Deref# for RangeInclusiveStartWrapperrust-analyzer cargo rangemap 1.7.1 range_wrapper/RangeInclusiveStartWrapper#<T> { |
| 200 | type Targetrust-analyzer cargo rangemap 1.7.1 range_wrapper/impl#[`RangeInclusiveStartWrapper<T>`][Deref]Target# = RangeInclusiveEndWrapperrust-analyzer cargo rangemap 1.7.1 range_wrapper/RangeInclusiveEndWrapper#<T>; |
| 201 | |
| 202 | fn derefrust-analyzer cargo rangemap 1.7.1 range_wrapper/impl#[`RangeInclusiveStartWrapper<T>`][Deref]deref().(&self) -> &Selfrust-analyzer cargo rangemap 1.7.1 range_wrapper/impl#[`RangeInclusiveStartWrapper<T>`][Deref]::Targetrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/Deref#Target# { |
| 203 | &self.end_wrapperrust-analyzer cargo rangemap 1.7.1 range_wrapper/RangeInclusiveStartWrapper#end_wrapper. |
| 204 | } |
| 205 | } |
| 206 | |
| 207 | // |
| 208 | // RangeInclusive end wrapper |
| 209 | // |
| 210 | |
| 211 | #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Eq:, Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/macros/Debug:, Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone:)] |
| 212 | pub struct RangeInclusiveEndWrapperrust-analyzer cargo rangemap 1.7.1 range_wrapper/RangeInclusiveEndWrapper#<T> { |
| 213 | pub rangerust-analyzer cargo rangemap 1.7.1 range_wrapper/RangeInclusiveEndWrapper#range.: RangeInclusiverust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/RangeInclusive#<T>, |
| 214 | } |
| 215 | |
| 216 | impl<T> RangeInclusiveEndWrapperrust-analyzer cargo rangemap 1.7.1 range_wrapper/RangeInclusiveEndWrapper#<T> { |
| 217 | pub fn newrust-analyzer cargo rangemap 1.7.1 range_wrapper/impl#[`RangeInclusiveEndWrapper<T>`]new().(range: RangeInclusiverust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/RangeInclusive#<T>) -> RangeInclusiveEndWrapperrust-analyzer cargo rangemap 1.7.1 range_wrapper/RangeInclusiveEndWrapper#<T> { |
| 218 | RangeInclusiveEndWrapperrust-analyzer cargo rangemap 1.7.1 range_wrapper/RangeInclusiveEndWrapper# { rangerust-analyzer cargo rangemap 1.7.1 range_wrapper/RangeInclusiveEndWrapper#range. } |
| 219 | } |
| 220 | } |
| 221 | |
| 222 | impl<T> PartialEqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq# for RangeInclusiveEndWrapperrust-analyzer cargo rangemap 1.7.1 range_wrapper/RangeInclusiveEndWrapper#<T> |
| 223 | where |
| 224 | T: PartialEqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq#, |
| 225 | { |
| 226 | fn eqrust-analyzer cargo rangemap 1.7.1 range_wrapper/impl#[`RangeInclusiveEndWrapper<T>`][`PartialEq<Self>`]eq().(&self, other: &RangeInclusiveEndWrapperrust-analyzer cargo rangemap 1.7.1 range_wrapper/RangeInclusiveEndWrapper#<T>) -> bool { |
| 227 | self.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 cmp/impls/impl#[`&A`][`PartialEq<&B>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialEq<&B>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialEq<&B>`]eq().other.endrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/impl#[`RangeInclusive<Idx>`]end().() |
| 228 | } |
| 229 | } |
| 230 | |
| 231 | impl<T> Ordrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Ord# for RangeInclusiveEndWrapperrust-analyzer cargo rangemap 1.7.1 range_wrapper/RangeInclusiveEndWrapper#<T> |
| 232 | where |
| 233 | T: Ordrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Ord#, |
| 234 | { |
| 235 | fn cmprust-analyzer cargo rangemap 1.7.1 range_wrapper/impl#[`RangeInclusiveEndWrapper<T>`][Ord]cmp().(&self, other: &RangeInclusiveEndWrapperrust-analyzer cargo rangemap 1.7.1 range_wrapper/RangeInclusiveEndWrapper#<T>) -> Orderingrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Ordering# { |
| 236 | self.endrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/impl#[`RangeInclusive<Idx>`]end().().cmprust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Ord#cmp().(other.endrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/impl#[`RangeInclusive<Idx>`]end().()) |
| 237 | } |
| 238 | } |
| 239 | |
| 240 | impl<T> PartialOrdrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialOrd# for RangeInclusiveEndWrapperrust-analyzer cargo rangemap 1.7.1 range_wrapper/RangeInclusiveEndWrapper#<T> |
| 241 | where |
| 242 | T: PartialOrdrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialOrd#, |
| 243 | { |
| 244 | fn partial_cmprust-analyzer cargo rangemap 1.7.1 range_wrapper/impl#[`RangeInclusiveEndWrapper<T>`][`PartialOrd<Self>`]partial_cmp().(&self, other: &RangeInclusiveEndWrapperrust-analyzer cargo rangemap 1.7.1 range_wrapper/RangeInclusiveEndWrapper#<T>) -> 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#> { |
| 245 | self.endrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/impl#[`RangeInclusive<Idx>`]end().().partial_cmprust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialOrd#partial_cmp().(other.endrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/impl#[`RangeInclusive<Idx>`]end().()) |
| 246 | } |
| 247 | } |
| 248 | |
| 249 | // Avoid the need to tediously plumb through the layers of wrapper structs |
| 250 | // when you're just trying to access members of the inner range itself. |
| 251 | impl<T> Derefrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/Deref# for RangeInclusiveEndWrapperrust-analyzer cargo rangemap 1.7.1 range_wrapper/RangeInclusiveEndWrapper#<T> { |
| 252 | type Targetrust-analyzer cargo rangemap 1.7.1 range_wrapper/impl#[`RangeInclusiveEndWrapper<T>`][Deref]Target# = RangeInclusiverust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/RangeInclusive#<T>; |
| 253 | |
| 254 | fn derefrust-analyzer cargo rangemap 1.7.1 range_wrapper/impl#[`RangeInclusiveEndWrapper<T>`][Deref]deref().(&self) -> &Selfrust-analyzer cargo rangemap 1.7.1 range_wrapper/impl#[`RangeInclusiveEndWrapper<T>`][Deref]::Targetrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/Deref#Target# { |
| 255 | &self.rangerust-analyzer cargo rangemap 1.7.1 range_wrapper/RangeInclusiveEndWrapper#range. |
| 256 | } |
| 257 | } |