| 1 | 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#; |
| 2 | use corerust-analyzer cargo core https://github.com/rust-lang/rust/library/core crate/::ptrrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ptr/; |
| 3 | |
| 4 | #[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:, 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:)] |
| 5 | pub struct AsciiStrrust-analyzer cargo fast-float2 0.2.3 common/AsciiStr#<'a> { |
| 6 | ptrrust-analyzer cargo fast-float2 0.2.3 common/AsciiStr#ptr.: *const u8, |
| 7 | endrust-analyzer cargo fast-float2 0.2.3 common/AsciiStr#end.: *const u8, |
| 8 | _markerrust-analyzer cargo fast-float2 0.2.3 common/AsciiStr#_marker.: PhantomDatarust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/PhantomData#<&'a [u8]>, |
| 9 | } |
| 10 | |
| 11 | impl<'a> AsciiStrrust-analyzer cargo fast-float2 0.2.3 common/AsciiStr#<'a> { |
| 12 | #[inline] |
| 13 | pub fn newrust-analyzer cargo fast-float2 0.2.3 common/impl#[`AsciiStr<'a>`]new().(s: &'a [u8]) -> Selfrust-analyzer cargo fast-float2 0.2.3 common/impl#[`AsciiStr<'a>`] { |
| 14 | Selfrust-analyzer cargo fast-float2 0.2.3 common/impl#[`AsciiStr<'a>`] { |
| 15 | ptrrust-analyzer cargo fast-float2 0.2.3 common/AsciiStr#ptr.: s.as_ptrrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]as_ptr().(), |
| 16 | endrust-analyzer cargo fast-float2 0.2.3 common/AsciiStr#end.: unsafe { s.as_ptrrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]as_ptr().().addrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ptr/const_ptr/impl#[`*const T`]add().(s.lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]len().()) }, |
| 17 | _markerrust-analyzer cargo fast-float2 0.2.3 common/AsciiStr#_marker.: PhantomDatarust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/PhantomData#, |
| 18 | } |
| 19 | } |
| 20 | |
| 21 | pub fn lenrust-analyzer cargo fast-float2 0.2.3 common/impl#[`AsciiStr<'a>`]len().(&self) -> isize { |
| 22 | self.endrust-analyzer cargo fast-float2 0.2.3 common/AsciiStr#end. as isize rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[isize][`Sub<Self>`]sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[isize][`Sub<Self>`]sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[isize][`Sub<Self>`]sub().self.ptrrust-analyzer cargo fast-float2 0.2.3 common/AsciiStr#ptr. as isize |
| 23 | } |
| 24 | |
| 25 | /// # Safety |
| 26 | /// |
| 27 | /// Safe if `n <= self.len()` |
| 28 | #[inline] |
| 29 | pub unsafe fn step_byrust-analyzer cargo fast-float2 0.2.3 common/impl#[`AsciiStr<'a>`]step_by().(&mut self, n: usize) -> &mut Selfrust-analyzer cargo fast-float2 0.2.3 common/impl#[`AsciiStr<'a>`] { |
| 30 | debug_assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/debug_assert!!( |
| 31 | // FIXME: remove when we drop support for < 1.43.0 |
| 32 | n <rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]lt(). isize::max_valuerust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/impl#[isize]max_value().() as usize && n as isize <= self.lenrust-analyzer cargo fast-float2 0.2.3 common/impl#[`AsciiStr<'a>`]len().(), |
| 33 | "buffer overflow: stepping by greater than our buffer length." |
| 34 | ); |
| 35 | // SAFETY: Safe if `n <= self.len()` |
| 36 | unsafe { self.ptrrust-analyzer cargo fast-float2 0.2.3 common/AsciiStr#ptr. = self.ptrrust-analyzer cargo fast-float2 0.2.3 common/AsciiStr#ptr..addrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ptr/const_ptr/impl#[`*const T`]add().(n) }; |
| 37 | self |
| 38 | } |
| 39 | |
| 40 | /// # Safety |
| 41 | /// |
| 42 | /// Safe if `!self.is_empty()` |
| 43 | #[inline] |
| 44 | pub unsafe fn steprust-analyzer cargo fast-float2 0.2.3 common/impl#[`AsciiStr<'a>`]step().(&mut self) -> &mut Selfrust-analyzer cargo fast-float2 0.2.3 common/impl#[`AsciiStr<'a>`] { |
| 45 | debug_assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/debug_assert!!(!rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().self.is_emptyrust-analyzer cargo fast-float2 0.2.3 common/impl#[`AsciiStr<'a>`]is_empty().(), "buffer overflow: buffer is empty."); |
| 46 | // SAFETY: Safe if the buffer is not empty, that is, `self.len() >= 1` |
| 47 | unsafe { self.step_byrust-analyzer cargo fast-float2 0.2.3 common/impl#[`AsciiStr<'a>`]step_by().(1) } |
| 48 | } |
| 49 | |
| 50 | #[inline] |
| 51 | pub fn step_ifrust-analyzer cargo fast-float2 0.2.3 common/impl#[`AsciiStr<'a>`]step_if().(&mut self, c: u8) -> bool { |
| 52 | let stepped = self.first_isrust-analyzer cargo fast-float2 0.2.3 common/impl#[`AsciiStr<'a>`]first_is().(c); |
| 53 | if stepped { |
| 54 | // SAFETY: safe since we have at least 1 character in the buffer |
| 55 | unsafe { self.steprust-analyzer cargo fast-float2 0.2.3 common/impl#[`AsciiStr<'a>`]step().() }; |
| 56 | } |
| 57 | stepped |
| 58 | } |
| 59 | |
| 60 | #[inline] |
| 61 | pub fn is_emptyrust-analyzer cargo fast-float2 0.2.3 common/impl#[`AsciiStr<'a>`]is_empty().(&self) -> bool { |
| 62 | self.ptrrust-analyzer cargo fast-float2 0.2.3 common/AsciiStr#ptr. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ptr/const_ptr/impl#[`*const T`][`PartialEq<Self>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ptr/const_ptr/impl#[`*const T`][`PartialEq<Self>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ptr/const_ptr/impl#[`*const T`][`PartialEq<Self>`]eq().self.endrust-analyzer cargo fast-float2 0.2.3 common/AsciiStr#end. |
| 63 | } |
| 64 | |
| 65 | /// # Safety |
| 66 | /// |
| 67 | /// Safe if `!self.is_empty()` |
| 68 | #[inline] |
| 69 | pub unsafe fn first_uncheckedrust-analyzer cargo fast-float2 0.2.3 common/impl#[`AsciiStr<'a>`]first_unchecked().(&self) -> u8 { |
| 70 | debug_assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/debug_assert!!(!rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().self.is_emptyrust-analyzer cargo fast-float2 0.2.3 common/impl#[`AsciiStr<'a>`]is_empty().(), "attempting to get first value of empty buffer."); |
| 71 | unsafe { *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/Deref#deref().self.ptrrust-analyzer cargo fast-float2 0.2.3 common/AsciiStr#ptr. } |
| 72 | } |
| 73 | |
| 74 | #[inline] |
| 75 | pub fn firstrust-analyzer cargo fast-float2 0.2.3 common/impl#[`AsciiStr<'a>`]first().(&self) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<u8> { |
| 76 | if self.is_emptyrust-analyzer cargo fast-float2 0.2.3 common/impl#[`AsciiStr<'a>`]is_empty().() { |
| 77 | Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None# |
| 78 | } else { |
| 79 | // SAFETY: safe since `!self.is_empty()` |
| 80 | Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(unsafe { self.first_uncheckedrust-analyzer cargo fast-float2 0.2.3 common/impl#[`AsciiStr<'a>`]first_unchecked().() }) |
| 81 | } |
| 82 | } |
| 83 | |
| 84 | #[inline] |
| 85 | pub fn first_isrust-analyzer cargo fast-float2 0.2.3 common/impl#[`AsciiStr<'a>`]first_is().(&self, c: u8) -> bool { |
| 86 | self.firstrust-analyzer cargo fast-float2 0.2.3 common/impl#[`AsciiStr<'a>`]first().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`][`PartialEq<Self>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`][`PartialEq<Self>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`][`PartialEq<Self>`]eq().Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(c) |
| 87 | } |
| 88 | |
| 89 | #[inline] |
| 90 | pub fn first_is2rust-analyzer cargo fast-float2 0.2.3 common/impl#[`AsciiStr<'a>`]first_is2().(&self, c1: u8, c2: u8) -> bool { |
| 91 | self.firstrust-analyzer cargo fast-float2 0.2.3 common/impl#[`AsciiStr<'a>`]first().().map_orrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]map_or().(false, |c| c 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().c1 || c 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().c2) |
| 92 | } |
| 93 | |
| 94 | #[inline] |
| 95 | pub fn first_is_digitrust-analyzer cargo fast-float2 0.2.3 common/impl#[`AsciiStr<'a>`]first_is_digit().(&self) -> bool { |
| 96 | self.firstrust-analyzer cargo fast-float2 0.2.3 common/impl#[`AsciiStr<'a>`]first().().map_orrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]map_or().(false, |c| c.is_ascii_digitrust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/impl#[u8]is_ascii_digit().()) |
| 97 | } |
| 98 | |
| 99 | #[inline] |
| 100 | pub fn first_digitrust-analyzer cargo fast-float2 0.2.3 common/impl#[`AsciiStr<'a>`]first_digit().(&self) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<u8> { |
| 101 | self.firstrust-analyzer cargo fast-float2 0.2.3 common/impl#[`AsciiStr<'a>`]first().().and_thenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]and_then().(|x| { |
| 102 | if x.is_ascii_digitrust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/impl#[u8]is_ascii_digit().() { |
| 103 | Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(x rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u8][`Sub<Self>`]sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u8][`Sub<Self>`]sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u8][`Sub<Self>`]sub().b'0') |
| 104 | } else { |
| 105 | Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None# |
| 106 | } |
| 107 | }) |
| 108 | } |
| 109 | |
| 110 | #[inline] |
| 111 | pub fn try_read_digitrust-analyzer cargo fast-float2 0.2.3 common/impl#[`AsciiStr<'a>`]try_read_digit().(&mut self) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<u8> { |
| 112 | let digit = self.first_digitrust-analyzer cargo fast-float2 0.2.3 common/impl#[`AsciiStr<'a>`]first_digit().()?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`][Try]branch().; |
| 113 | // SAFETY: Safe since `first_digit` means the buffer is not empty |
| 114 | unsafe { self.steprust-analyzer cargo fast-float2 0.2.3 common/impl#[`AsciiStr<'a>`]step().() }; |
| 115 | Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(digit) |
| 116 | } |
| 117 | |
| 118 | #[inline] |
| 119 | pub fn parse_digitsrust-analyzer cargo fast-float2 0.2.3 common/impl#[`AsciiStr<'a>`]parse_digits().(&mut self, mut func: impl FnMutrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/function/FnMut#(u8)) { |
| 120 | while let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(digit) = self.try_read_digitrust-analyzer cargo fast-float2 0.2.3 common/impl#[`AsciiStr<'a>`]try_read_digit().() { |
| 121 | func(digit); |
| 122 | } |
| 123 | } |
| 124 | |
| 125 | #[inline] |
| 126 | pub fn try_read_u64rust-analyzer cargo fast-float2 0.2.3 common/impl#[`AsciiStr<'a>`]try_read_u64().(&self) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<u64> { |
| 127 | if self.lenrust-analyzer cargo fast-float2 0.2.3 common/impl#[`AsciiStr<'a>`]len().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[isize][`PartialOrd<Self>`]ge().>=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[isize][`PartialOrd<Self>`]ge(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[isize][`PartialOrd<Self>`]ge().8 { |
| 128 | Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(unsafe { self.read_u64_uncheckedrust-analyzer cargo fast-float2 0.2.3 common/impl#[`AsciiStr<'a>`]read_u64_unchecked().() }) |
| 129 | } else { |
| 130 | Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None# |
| 131 | } |
| 132 | } |
| 133 | |
| 134 | /// # Safety |
| 135 | /// |
| 136 | /// Safe if `self.len() >= 8` |
| 137 | #[inline] |
| 138 | #[allow(clippy::cast_ptr_alignment)] |
| 139 | pub unsafe fn read_u64_uncheckedrust-analyzer cargo fast-float2 0.2.3 common/impl#[`AsciiStr<'a>`]read_u64_unchecked().(&self) -> u64 { |
| 140 | debug_assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/debug_assert!!(self.lenrust-analyzer cargo fast-float2 0.2.3 common/impl#[`AsciiStr<'a>`]len().() >= 8, "overflowing buffer: buffer is not 8 bytes long"); |
| 141 | let src = self.ptrrust-analyzer cargo fast-float2 0.2.3 common/AsciiStr#ptr. as *const u64; |
| 142 | // SAFETY: Safe if `self.len() >= 8` |
| 143 | u64::from_lerust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/impl#[u64]from_le().(unsafe { ptrrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ptr/::read_unalignedrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ptr/read_unaligned().(src) }) |
| 144 | } |
| 145 | |
| 146 | #[inline] |
| 147 | pub fn offset_fromrust-analyzer cargo fast-float2 0.2.3 common/impl#[`AsciiStr<'a>`]offset_from().(&self, other: &Selfrust-analyzer cargo fast-float2 0.2.3 common/impl#[`AsciiStr<'a>`]) -> isize { |
| 148 | isize::wrapping_subrust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/impl#[isize]wrapping_sub().(self.ptrrust-analyzer cargo fast-float2 0.2.3 common/AsciiStr#ptr. as isize, other.ptrrust-analyzer cargo fast-float2 0.2.3 common/AsciiStr#ptr. as isize) // assuming the same end |
| 149 | } |
| 150 | } |
| 151 | |
| 152 | // Most of these are inherently unsafe; we assume we know what we're calling and |
| 153 | // when. |
| 154 | pub trait ByteSlicerust-analyzer cargo fast-float2 0.2.3 common/ByteSlice#: AsRefrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/AsRef#<[u8]> + AsMutrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/AsMut#<[u8]> { |
| 155 | #[inline] |
| 156 | fn check_firstrust-analyzer cargo fast-float2 0.2.3 common/ByteSlice#check_first().(&self, c: u8) -> bool { |
| 157 | self.as_refrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/AsRef#as_ref().().firstrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]first().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`][`PartialEq<Self>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`][`PartialEq<Self>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`][`PartialEq<Self>`]eq().Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(&c) |
| 158 | } |
| 159 | |
| 160 | #[inline] |
| 161 | fn check_first2rust-analyzer cargo fast-float2 0.2.3 common/ByteSlice#check_first2().(&self, c1: u8, c2: u8) -> bool { |
| 162 | if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(&c) = self.as_refrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/AsRef#as_ref().().firstrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]first().() { |
| 163 | c 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().c1 || c 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().c2 |
| 164 | } else { |
| 165 | false |
| 166 | } |
| 167 | } |
| 168 | |
| 169 | #[inline] |
| 170 | fn eq_ignore_caserust-analyzer cargo fast-float2 0.2.3 common/ByteSlice#eq_ignore_case().(&self, u: &[u8]) -> bool { |
| 171 | let s = self.as_refrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/AsRef#as_ref().(); |
| 172 | if s.lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]len().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]lt().<rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]lt(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]lt().u.lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]len().() { |
| 173 | return false; |
| 174 | } |
| 175 | let d = (0..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#u.lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]len().()).foldrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#fold().(0, |d, i| d rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u8][`BitOr<Self>`]bitor().|rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u8][`BitOr<Self>`]bitor(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u8][`BitOr<Self>`]bitor().s[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().i]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u8][`BitXor<Self>`]bitxor().^rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u8][`BitXor<Self>`]bitxor(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u8][`BitXor<Self>`]bitxor().u[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().i]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().); |
| 176 | d 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().0 || d 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().32 |
| 177 | } |
| 178 | |
| 179 | #[inline] |
| 180 | fn advancerust-analyzer cargo fast-float2 0.2.3 common/ByteSlice#advance().(&self, n: usize) -> &[u8] { |
| 181 | &self.as_refrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/AsRef#as_ref().()[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().n..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/RangeFrom#]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index(). |
| 182 | } |
| 183 | |
| 184 | #[inline] |
| 185 | fn skip_charsrust-analyzer cargo fast-float2 0.2.3 common/ByteSlice#skip_chars().(&self, c: u8) -> &[u8] { |
| 186 | let mut s = self.as_refrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/AsRef#as_ref().(); |
| 187 | while s.check_firstrust-analyzer cargo fast-float2 0.2.3 common/ByteSlice#check_first().(c) { |
| 188 | s = s.advancerust-analyzer cargo fast-float2 0.2.3 common/ByteSlice#advance().(1); |
| 189 | } |
| 190 | s |
| 191 | } |
| 192 | |
| 193 | /// # Safety |
| 194 | /// |
| 195 | /// Safe if `self.len() >= 8`. |
| 196 | #[inline] |
| 197 | #[allow(clippy::cast_ptr_alignment)] |
| 198 | unsafe fn read_u64rust-analyzer cargo fast-float2 0.2.3 common/ByteSlice#read_u64().(&self) -> u64 { |
| 199 | debug_assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/debug_assert!!(self.as_refrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/AsRef#as_ref().().lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]len().() >= 8); |
| 200 | let src = self.as_refrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/AsRef#as_ref().().as_ptrrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]as_ptr().() as *const u64; |
| 201 | // SAFETY: safe if `self.len() >= 8`. |
| 202 | u64::from_lerust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/impl#[u64]from_le().(unsafe { ptrrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ptr/::read_unalignedrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ptr/read_unaligned().(src) }) |
| 203 | } |
| 204 | |
| 205 | /// # Safety |
| 206 | /// |
| 207 | /// Safe if `self.len() >= 8`. |
| 208 | #[inline] |
| 209 | #[allow(clippy::cast_ptr_alignment)] |
| 210 | unsafe fn write_u64rust-analyzer cargo fast-float2 0.2.3 common/ByteSlice#write_u64().(&mut self, value: u64) { |
| 211 | debug_assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/debug_assert!!(self.as_refrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[`&mut T`][`AsRef<U>`]as_ref().().lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]len().() >= 8); |
| 212 | let dst = self.as_mutrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/AsMut#as_mut().().as_mut_ptrrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]as_mut_ptr().() as *mut u64; |
| 213 | // SAFETY: safe if `self.len() >= 8`. |
| 214 | unsafe { ptrrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ptr/::write_unalignedrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ptr/write_unaligned().(dst, u64::to_lerust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/impl#[u64]to_le().(value)) }; |
| 215 | } |
| 216 | } |
| 217 | |
| 218 | impl ByteSlicerust-analyzer cargo fast-float2 0.2.3 common/ByteSlice# for [u8] { |
| 219 | } |
| 220 | |
| 221 | #[inline] |
| 222 | pub fn is_8digitsrust-analyzer cargo fast-float2 0.2.3 common/is_8digits().(v: u64) -> bool { |
| 223 | let a = v.wrapping_addrust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/impl#[u64]wrapping_add().(0x4646_4646_4646_4646); |
| 224 | let b = v.wrapping_subrust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/impl#[u64]wrapping_sub().(0x3030_3030_3030_3030); |
| 225 | (a rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u64][`BitOr<Self>`]bitor().|rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u64][`BitOr<Self>`]bitor(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u64][`BitOr<Self>`]bitor().b) rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u64][`BitAnd<Self>`]bitand().&rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u64][`BitAnd<Self>`]bitand(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u64][`BitAnd<Self>`]bitand().0x8080_8080_8080_8080 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u64][`PartialEq<Self>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u64][`PartialEq<Self>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u64][`PartialEq<Self>`]eq().0 |
| 226 | } |
| 227 | |
| 228 | #[inline] |
| 229 | pub fn parse_digitsrust-analyzer cargo fast-float2 0.2.3 common/parse_digits().(s: &mut &[u8], mut f: impl FnMutrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/function/FnMut#(u8)) { |
| 230 | while let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(&ch) = s.firstrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]first().() { |
| 231 | let c = ch.wrapping_subrust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/impl#[u8]wrapping_sub().(b'0'); |
| 232 | if c rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialOrd<Self>`]lt().<rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialOrd<Self>`]lt(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialOrd<Self>`]lt().10 { |
| 233 | f(c); |
| 234 | *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&mut T`][Deref]deref().s = s.advancerust-analyzer cargo fast-float2 0.2.3 common/ByteSlice#advance().(1); |
| 235 | } else { |
| 236 | break; |
| 237 | } |
| 238 | } |
| 239 | } |
| 240 | |
| 241 | #[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:, Copyrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Copy:, Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone:, 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:, Defaultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core default/Default:)] |
| 242 | pub struct AdjustedMantissarust-analyzer cargo fast-float2 0.2.3 common/AdjustedMantissa# { |
| 243 | pub mantissarust-analyzer cargo fast-float2 0.2.3 common/AdjustedMantissa#mantissa.: u64, |
| 244 | pub power2rust-analyzer cargo fast-float2 0.2.3 common/AdjustedMantissa#power2.: i32, |
| 245 | } |
| 246 | |
| 247 | impl AdjustedMantissarust-analyzer cargo fast-float2 0.2.3 common/AdjustedMantissa# { |
| 248 | #[inline] |
| 249 | pub const fn zero_pow2rust-analyzer cargo fast-float2 0.2.3 common/impl#[AdjustedMantissa]zero_pow2().(power2: i32) -> Selfrust-analyzer cargo fast-float2 0.2.3 common/impl#[AdjustedMantissa] { |
| 250 | Selfrust-analyzer cargo fast-float2 0.2.3 common/impl#[AdjustedMantissa] { |
| 251 | mantissarust-analyzer cargo fast-float2 0.2.3 common/AdjustedMantissa#mantissa.: 0, |
| 252 | power2rust-analyzer cargo fast-float2 0.2.3 common/AdjustedMantissa#power2., |
| 253 | } |
| 254 | } |
| 255 | } |
| 256 | |
| 257 | #[cfg(test)] |
| 258 | mod testsrust-analyzer cargo fast-float2 0.2.3 common/tests/ { |
| 259 | use superrust-analyzer cargo fast-float2 0.2.3 common/::*; |
| 260 | |
| 261 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 262 | fn test_read_write_u64rust-analyzer cargo fast-float2 0.2.3 common/tests/test_read_write_u64().() { |
| 263 | let bytes = b"01234567"; |
| 264 | let string = AsciiStrrust-analyzer cargo fast-float2 0.2.3 common/AsciiStr#::newrust-analyzer cargo fast-float2 0.2.3 common/impl#[`AsciiStr<'a>`]new().(bytes); |
| 265 | let int = string.try_read_u64rust-analyzer cargo fast-float2 0.2.3 common/impl#[`AsciiStr<'a>`]try_read_u64().(); |
| 266 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(int, Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(0x3736353433323130)); |
| 267 | |
| 268 | let int = unsafe { bytes.read_u64rust-analyzer cargo fast-float2 0.2.3 common/ByteSlice#read_u64().() }; |
| 269 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(int, 0x3736353433323130); |
| 270 | |
| 271 | let mut slc = [0u8; 8]; |
| 272 | unsafe { slc.write_u64rust-analyzer cargo fast-float2 0.2.3 common/ByteSlice#write_u64().(0x3736353433323130) }; |
| 273 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(&slc, bytes); |
| 274 | } |
| 275 | } |