1pub(crate) const fn max_usize(l: usize, r: usize) -> usize {
2 if l > r {
3 l
4 } else {
5 r
6 }
7}
8pub(crate) const fn saturating_add(l: usize, r: usize) -> usize {
9 let (sum: usize, overflowed: bool) = l.overflowing_add(r);
10 if overflowed {
11 usize::MAX
12 } else {
13 sum
14 }
15}
16
17pub(crate) const fn is_char_boundary_no_len_check(str: &[u8], index: usize) -> bool {
18 index == str.len() || (str[index] as i8) >= -0x40
19}
20
21#[repr(C)]
22pub union PtrToRef<'a, T: ?Sized> {
23 pub ptr: *const T,
24 pub reff: &'a T,
25}
26