use super::unicode::{is_blank, is_line_ending};
pub(crate) fn read_until(byte: u8, bytes: &[u8]) -> usize {
let mut escaped = false;
bytes.iter().take_while(|&&c| {
if escaped {
escaped = false;
return true
}
if c == b'\\' {
escaped = true;
}
c != byte
}).count()
}
pub(crate) fn read_line(bytes: &[u8]) -> usize {
bytes.iter().take_while(|c| !is_line_ending(**c)).count()
}
pub(crate) fn read_while<P>(bytes: &[u8], mut pred: P) -> usize
where
P: FnMut(u8) -> bool,
{
bytes.iter().take_while(|&&c| pred(c)).count()
}
pub(crate) fn read_indentation(bytes: &[u8]) -> usize {
bytes.iter().take_while(|&&c| is_blank(c)).count()
}