| 1 | use regex_syntaxrust-analyzer cargo regex-syntax 0.8.5 crate/::hirrust-analyzer cargo regex-syntax 0.8.5 hir/::ClassBytesRangerust-analyzer cargo regex-syntax 0.8.5 hir/ClassBytesRange#; |
| 2 | use regex_syntaxrust-analyzer cargo regex-syntax 0.8.5 crate/::hirrust-analyzer cargo regex-syntax 0.8.5 hir/::ClassUnicodeRangerust-analyzer cargo regex-syntax 0.8.5 hir/ClassUnicodeRange#; |
| 3 | use regex_syntaxrust-analyzer cargo regex-syntax 0.8.5 crate/::utf8rust-analyzer cargo regex-syntax 0.8.5 utf8/::Utf8Rangerust-analyzer cargo regex-syntax 0.8.5 utf8/Utf8Range#; |
| 4 | |
| 5 | use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::cmprust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/::{Ordrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Ord#, Orderingrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Ordering#}; |
| 6 | |
| 7 | #[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:, Copyrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Copy:, PartialEqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq:, Eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Eq:, Hashrust-analyzer cargo core https://github.com/rust-lang/rust/library/core hash/macros/Hash:)] |
| 8 | pub struct Rangerust-analyzer cargo logos-codegen 0.15.1 graph/range/Range# { |
| 9 | pub startrust-analyzer cargo logos-codegen 0.15.1 graph/range/Range#start.: u8, |
| 10 | pub endrust-analyzer cargo logos-codegen 0.15.1 graph/range/Range#end.: u8, |
| 11 | } |
| 12 | |
| 13 | impl Rangerust-analyzer cargo logos-codegen 0.15.1 graph/range/Range# { |
| 14 | pub fn as_byterust-analyzer cargo logos-codegen 0.15.1 graph/range/impl#[Range]as_byte().(&self) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<u8> { |
| 15 | if self.is_byterust-analyzer cargo logos-codegen 0.15.1 graph/range/impl#[Range]is_byte().() { |
| 16 | Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(self.startrust-analyzer cargo logos-codegen 0.15.1 graph/range/Range#start.) |
| 17 | } else { |
| 18 | Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None# |
| 19 | } |
| 20 | } |
| 21 | |
| 22 | pub fn is_byterust-analyzer cargo logos-codegen 0.15.1 graph/range/impl#[Range]is_byte().(&self) -> bool { |
| 23 | self.startrust-analyzer cargo logos-codegen 0.15.1 graph/range/Range#start. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialEq<Self>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialEq<Self>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialEq<Self>`]eq().self.endrust-analyzer cargo logos-codegen 0.15.1 graph/range/Range#end. |
| 24 | } |
| 25 | } |
| 26 | |
| 27 | impl Fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/From#<u8> for Rangerust-analyzer cargo logos-codegen 0.15.1 graph/range/Range# { |
| 28 | fn fromrust-analyzer cargo logos-codegen 0.15.1 graph/range/impl#[Range][`From<u8>`]from().(byte: u8) -> Rangerust-analyzer cargo logos-codegen 0.15.1 graph/range/Range# { |
| 29 | Rangerust-analyzer cargo logos-codegen 0.15.1 graph/range/Range# { |
| 30 | startrust-analyzer cargo logos-codegen 0.15.1 graph/range/Range#start.: byte, |
| 31 | endrust-analyzer cargo logos-codegen 0.15.1 graph/range/Range#end.: byte, |
| 32 | } |
| 33 | } |
| 34 | } |
| 35 | |
| 36 | impl Fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/From#<&u8> for Rangerust-analyzer cargo logos-codegen 0.15.1 graph/range/Range# { |
| 37 | fn fromrust-analyzer cargo logos-codegen 0.15.1 graph/range/impl#[Range][`From<&u8>`]from().(byte: &u8) -> Rangerust-analyzer cargo logos-codegen 0.15.1 graph/range/Range# { |
| 38 | Rangerust-analyzer cargo logos-codegen 0.15.1 graph/range/Range#::fromrust-analyzer cargo logos-codegen 0.15.1 graph/range/impl#[Range][`From<u8>`]from().(*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().byte) |
| 39 | } |
| 40 | } |
| 41 | |
| 42 | impl Iteratorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator# for Rangerust-analyzer cargo logos-codegen 0.15.1 graph/range/Range# { |
| 43 | type Itemrust-analyzer cargo logos-codegen 0.15.1 graph/range/impl#[Range][Iterator]Item# = u8; |
| 44 | |
| 45 | fn nextrust-analyzer cargo logos-codegen 0.15.1 graph/range/impl#[Range][Iterator]next().(&mut self) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<u8> { |
| 46 | match self.startrust-analyzer cargo logos-codegen 0.15.1 graph/range/Range#start..cmprust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][Ord]cmp().(&self.endrust-analyzer cargo logos-codegen 0.15.1 graph/range/Range#end.) { |
| 47 | stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std 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#::Lessrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Ordering#Less# => { |
| 48 | let res = self.startrust-analyzer cargo logos-codegen 0.15.1 graph/range/Range#start.; |
| 49 | self.startrust-analyzer cargo logos-codegen 0.15.1 graph/range/Range#start. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u8][`AddAssign<Self>`]add_assign().+=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u8][`AddAssign<Self>`]add_assign(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u8][`AddAssign<Self>`]add_assign().1; |
| 50 | |
| 51 | Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(res) |
| 52 | } |
| 53 | stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std 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#::Equalrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Ordering#Equal# => { |
| 54 | let res = self.startrust-analyzer cargo logos-codegen 0.15.1 graph/range/Range#start.; |
| 55 | |
| 56 | // Necessary so that range 0xFF-0xFF doesn't loop forever |
| 57 | self.startrust-analyzer cargo logos-codegen 0.15.1 graph/range/Range#start. = 0xFF; |
| 58 | self.endrust-analyzer cargo logos-codegen 0.15.1 graph/range/Range#end. = 0x00; |
| 59 | |
| 60 | Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(res) |
| 61 | } |
| 62 | stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std 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#::Greaterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Ordering#Greater# => Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#, |
| 63 | } |
| 64 | } |
| 65 | } |
| 66 | |
| 67 | impl PartialOrdrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialOrd# for Rangerust-analyzer cargo logos-codegen 0.15.1 graph/range/Range# { |
| 68 | fn partial_cmprust-analyzer cargo logos-codegen 0.15.1 graph/range/impl#[Range][`PartialOrd<Self>`]partial_cmp().(&self, other: &Rangerust-analyzer cargo logos-codegen 0.15.1 graph/range/Range#) -> 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#> { |
| 69 | Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(self.cmprust-analyzer cargo logos-codegen 0.15.1 graph/range/impl#[Range][Ord]cmp().(other)) |
| 70 | } |
| 71 | } |
| 72 | |
| 73 | impl Ordrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Ord# for Rangerust-analyzer cargo logos-codegen 0.15.1 graph/range/Range# { |
| 74 | fn cmprust-analyzer cargo logos-codegen 0.15.1 graph/range/impl#[Range][Ord]cmp().(&self, other: &Selfrust-analyzer cargo logos-codegen 0.15.1 graph/range/impl#[Range][Ord]) -> Orderingrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Ordering# { |
| 75 | self.startrust-analyzer cargo logos-codegen 0.15.1 graph/range/Range#start..cmprust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][Ord]cmp().(&other.startrust-analyzer cargo logos-codegen 0.15.1 graph/range/Range#start.) |
| 76 | } |
| 77 | } |
| 78 | |
| 79 | impl Fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/From#<Utf8Rangerust-analyzer cargo regex-syntax 0.8.5 utf8/Utf8Range#> for Rangerust-analyzer cargo logos-codegen 0.15.1 graph/range/Range# { |
| 80 | fn fromrust-analyzer cargo logos-codegen 0.15.1 graph/range/impl#[Range][`From<Utf8Range>`]from().(r: Utf8Rangerust-analyzer cargo regex-syntax 0.8.5 utf8/Utf8Range#) -> Rangerust-analyzer cargo logos-codegen 0.15.1 graph/range/Range# { |
| 81 | Rangerust-analyzer cargo logos-codegen 0.15.1 graph/range/Range# { |
| 82 | startrust-analyzer cargo logos-codegen 0.15.1 graph/range/Range#start.: r.startrust-analyzer cargo regex-syntax 0.8.5 utf8/Utf8Range#start., |
| 83 | endrust-analyzer cargo logos-codegen 0.15.1 graph/range/Range#end.: r.endrust-analyzer cargo regex-syntax 0.8.5 utf8/Utf8Range#end., |
| 84 | } |
| 85 | } |
| 86 | } |
| 87 | |
| 88 | impl Fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/From#<ClassUnicodeRangerust-analyzer cargo regex-syntax 0.8.5 hir/ClassUnicodeRange#> for Rangerust-analyzer cargo logos-codegen 0.15.1 graph/range/Range# { |
| 89 | fn fromrust-analyzer cargo logos-codegen 0.15.1 graph/range/impl#[Range][`From<ClassUnicodeRange>`]from().(r: ClassUnicodeRangerust-analyzer cargo regex-syntax 0.8.5 hir/ClassUnicodeRange#) -> Rangerust-analyzer cargo logos-codegen 0.15.1 graph/range/Range# { |
| 90 | let start = r.startrust-analyzer cargo regex-syntax 0.8.5 hir/impl#[ClassUnicodeRange]start().() as u32; |
| 91 | let end = r.endrust-analyzer cargo regex-syntax 0.8.5 hir/impl#[ClassUnicodeRange]end().() as u32; |
| 92 | |
| 93 | if start rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u32][`PartialOrd<Self>`]ge().>=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u32][`PartialOrd<Self>`]ge(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u32][`PartialOrd<Self>`]ge().128 || end rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u32][`PartialOrd<Self>`]ge().>=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u32][`PartialOrd<Self>`]ge(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u32][`PartialOrd<Self>`]ge().128 && end rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u32][`PartialEq<Self>`]ne().!=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u32][`PartialEq<Self>`]ne(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u32][`PartialEq<Self>`]ne().0x0010FFFF { |
| 94 | panicrust-analyzer cargo std https://github.com/rust-lang/rust/library/std macros/panic!!("Casting non-ascii ClassUnicodeRange to Range") |
| 95 | } |
| 96 | |
| 97 | Rangerust-analyzer cargo logos-codegen 0.15.1 graph/range/Range# { |
| 98 | startrust-analyzer cargo logos-codegen 0.15.1 graph/range/Range#start.: start as u8, |
| 99 | endrust-analyzer cargo logos-codegen 0.15.1 graph/range/Range#end.: end as u8, |
| 100 | } |
| 101 | } |
| 102 | } |
| 103 | |
| 104 | impl Fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/From#<ClassBytesRangerust-analyzer cargo regex-syntax 0.8.5 hir/ClassBytesRange#> for Rangerust-analyzer cargo logos-codegen 0.15.1 graph/range/Range# { |
| 105 | fn fromrust-analyzer cargo logos-codegen 0.15.1 graph/range/impl#[Range][`From<ClassBytesRange>`]from().(r: ClassBytesRangerust-analyzer cargo regex-syntax 0.8.5 hir/ClassBytesRange#) -> Rangerust-analyzer cargo logos-codegen 0.15.1 graph/range/Range# { |
| 106 | Rangerust-analyzer cargo logos-codegen 0.15.1 graph/range/Range# { |
| 107 | startrust-analyzer cargo logos-codegen 0.15.1 graph/range/Range#start.: r.startrust-analyzer cargo regex-syntax 0.8.5 hir/impl#[ClassBytesRange]start().(), |
| 108 | endrust-analyzer cargo logos-codegen 0.15.1 graph/range/Range#end.: r.endrust-analyzer cargo regex-syntax 0.8.5 hir/impl#[ClassBytesRange]end().(), |
| 109 | } |
| 110 | } |
| 111 | } |
| 112 | |
| 113 | #[cfg(test)] |
| 114 | mod testsrust-analyzer cargo logos-codegen 0.15.1 graph/range/tests/ { |
| 115 | use superrust-analyzer cargo logos-codegen 0.15.1 graph/range/::*; |
| 116 | |
| 117 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 118 | fn range_iter_onerust-analyzer cargo logos-codegen 0.15.1 graph/range/tests/range_iter_one().() { |
| 119 | let byte = Rangerust-analyzer cargo logos-codegen 0.15.1 graph/range/Range#::fromrust-analyzer cargo logos-codegen 0.15.1 graph/range/impl#[Range][`From<u8>`]from().(b'!'); |
| 120 | let collected = byte.takerust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#take().(1000).collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().::<Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<_>>(); |
| 121 | |
| 122 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(b"!", &collected[rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index()...]rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index().); |
| 123 | } |
| 124 | |
| 125 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 126 | fn range_iter_fewrust-analyzer cargo logos-codegen 0.15.1 graph/range/tests/range_iter_few().() { |
| 127 | let byte = Rangerust-analyzer cargo logos-codegen 0.15.1 graph/range/Range# { |
| 128 | startrust-analyzer cargo logos-codegen 0.15.1 graph/range/Range#start.: b'a', |
| 129 | endrust-analyzer cargo logos-codegen 0.15.1 graph/range/Range#end.: b'd', |
| 130 | }; |
| 131 | let collected = byte.takerust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#take().(1000).collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().::<Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<_>>(); |
| 132 | |
| 133 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(b"abcd", &collected[rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index()...]rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index().); |
| 134 | } |
| 135 | |
| 136 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 137 | fn range_iter_boundsrust-analyzer cargo logos-codegen 0.15.1 graph/range/tests/range_iter_bounds().() { |
| 138 | let byte = Rangerust-analyzer cargo logos-codegen 0.15.1 graph/range/Range#::fromrust-analyzer cargo logos-codegen 0.15.1 graph/impls/debug/impl#[Range][`From<RangeInclusive<u8>>`]from().(0xFA..=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/RangeInclusive#0xFF); |
| 139 | |
| 140 | let collected = byte.takerust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#take().(1000).collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().::<Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<_>>(); |
| 141 | |
| 142 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(b"\xFA\xFB\xFC\xFD\xFE\xFF", &collected[rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index()...]rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index().); |
| 143 | } |
| 144 | } |