pub(crate) fn is_aligned_to(bytes: &[u8], align: usize) -> bool {
if !align.is_power_of_two() {
panic!("is_aligned_to: align is not a power-of-two");
}
bytes.as_ptr() as usize & (align - 1) == 0
}
pub fn align_to(bytes: &[u8], align: usize) -> Option<(&[u8], &[u8])> {
let offset = bytes.as_ptr().align_offset(align);
if bytes.len() < offset {
return None;
}
Some(bytes.split_at(offset))
}
pub fn align_to_type<T>(bytes: &[u8]) -> Option<(&[u8], &[u8])> {
align_to(bytes, core::mem::align_of::<T>())
}