Debian Codegraph @

src/algorithm.rs

raw symbols SCIP
1 //! Simple, shared algorithms for slices and iterators.
2
3 use craterust-analyzer cargo lexical-util 1.0.7 crate/::numrust-analyzer cargo lexical-util 1.0.7 num/::Integerrust-analyzer cargo lexical-util 1.0.7 num/Integer#;
4
5 /// Copy bytes from source to destination.
6 ///
7 /// This is only used in our compact and radix integer formatted, so
8 /// performance isn't the highest consideration here.
9 #[inline(always)]
10 #[cfg(any(feature = "write-floats", feature = "write-integers"))]
11 pub fn copy_to_dstrust-analyzer cargo lexical-util 1.0.7 algorithm/copy_to_dst().<T: Copyrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Copy#, Bytes: AsRefrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/AsRef#<[T]>>(dst: &mut [T], src: Bytes) -> usize {
12 let src = src.as_refrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/AsRef#as_ref().();
13 dst[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/IndexMut#index_mut()...rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/RangeTo#src.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 ops/index/IndexMut#index_mut()..copy_from_slicerust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]copy_from_slice().(src);
14
15 src.lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]len().()
16 }
17
18 /// Count the number of trailing characters equal to a given value.
19 #[inline(always)]
20 #[cfg(any(feature = "write-floats", feature = "write-integers"))]
21 pub fn rtrim_char_countrust-analyzer cargo lexical-util 1.0.7 algorithm/rtrim_char_count().(slc: &[u8], c: u8) -> usize {
22 slc.iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter().().revrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#rev().().take_whilerust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#take_while().(|&&si| si 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().c).countrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#count().()
23 }
24
25 /// Count the number of leading characters equal to a given value.
26 #[inline(always)]
27 #[cfg(any(feature = "write-floats", feature = "write-integers"))]
28 pub fn ltrim_char_countrust-analyzer cargo lexical-util 1.0.7 algorithm/ltrim_char_count().(slc: &[u8], c: u8) -> usize {
29 slc.iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter().().take_whilerust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#take_while().(|&&si| si 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().c).countrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#count().()
30 }
31
32 /// Check to see if parsing the float cannot possible overflow.
33 ///
34 /// This allows major optimizations for those types, since we can skip checked
35 /// arithmetic. Adapted from the rust [corelib][`core`].
36 ///
37 /// [`core`]: <https://doc.rust-lang.org/1.81.0/src/core/num/mod.rs.html#1389>
38 #[inline(always)]
39 pub fn cannot_overflowrust-analyzer cargo lexical-util 1.0.7 algorithm/cannot_overflow().<T: Integerrust-analyzer cargo lexical-util 1.0.7 num/Integer#>(length: usize, radix: u32) -> bool {
40 length rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]le().<=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]le(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]le().T::overflow_digitsrust-analyzer cargo lexical-util 1.0.7 num/Integer#overflow_digits().(radix)
41 }