use std::num::NonZero;
use crate::field::scan::Match;
pub(super) unsafe fn found(bytes: &[u8], index: usize) -> Match<'_> {
Match {
bytes,
end: unsafe { NonZero::new_unchecked(index + 1) },
}
}
pub(super) fn byte(found: Match<'_>) -> u8 {
unsafe { *found.bytes.get_unchecked(found.start()) }
}
pub(super) fn before<const INCLUDE: bool>(found: Match<'_>) -> &[u8] {
let end = found.end.get() - usize::from(!INCLUDE);
unsafe { found.bytes.get_unchecked(..end) }
}
pub(super) fn after<const INCLUDE: bool>(found: Match<'_>) -> &[u8] {
let start = found.end.get() - usize::from(INCLUDE);
unsafe { found.bytes.get_unchecked(start..) }
}