#[cfg(feature = "write")]
use core::ptr;
#[inline]
#[cfg(feature = "write")]
pub unsafe fn copy_to_dst<Bytes: AsRef<[u8]>>(dst: &mut [u8], src: Bytes) -> usize {
debug_assert!(dst.len() >= src.as_ref().len());
let src = src.as_ref();
unsafe { ptr::copy_nonoverlapping(src.as_ptr(), dst.as_mut_ptr(), src.len()) };
src.len()
}
#[inline]
#[cfg(feature = "write")]
pub fn rtrim_char_count(slc: &[u8], c: u8) -> usize {
slc.iter().rev().take_while(|&&si| si == c).count()
}
#[inline]
#[cfg(feature = "write")]
pub fn ltrim_char_count(slc: &[u8], c: u8) -> usize {
slc.iter().take_while(|&&si| si == c).count()
}
#[inline]
#[cfg(feature = "write")]
pub fn rtrim_char_slice(slc: &[u8], c: u8) -> (&[u8], usize) {
let count = rtrim_char_count(slc, c);
let index = slc.len() - count;
debug_assert!(count <= slc.len());
debug_assert!(index <= slc.len());
let slc = unsafe { slc.get_unchecked(..index) };
(slc, count)
}