lexical_util/
algorithm.rs1use crate::num::Integer;
4
5#[inline(always)]
10#[cfg(feature = "write")]
11pub fn copy_to_dst<T: Copy, Bytes: AsRef<[T]>>(dst: &mut [T], src: Bytes) -> usize {
12 let src = src.as_ref();
13 dst[..src.len()].copy_from_slice(src);
14
15 src.len()
16}
17
18#[inline(always)]
20#[cfg(feature = "write")]
21pub fn rtrim_char_count(slc: &[u8], c: u8) -> usize {
22 slc.iter().rev().take_while(|&&si| si == c).count()
23}
24
25#[inline(always)]
27#[cfg(feature = "write")]
28pub fn ltrim_char_count(slc: &[u8], c: u8) -> usize {
29 slc.iter().take_while(|&&si| si == c).count()
30}
31
32#[inline(always)]
41pub fn cannot_overflow<T: Integer>(length: usize, radix: u32) -> bool {
42 length <= T::overflow_digits(radix)
43}