mod core_support;
#[cfg(feature = "std")]
mod std_support;
#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
pub enum Expected {
Any(&'static [usize]),
Exact(usize),
Range {
min: usize,
max: usize,
},
}
#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
pub enum ParseError {
InvalidCharacter {
expected: &'static str,
found: char,
index: usize,
},
InvalidGroupCount {
expected: Expected,
found: usize,
},
InvalidGroupLength {
expected: Expected,
found: usize,
group: usize,
},
InvalidLength {
expected: Expected,
found: usize,
},
}
impl ParseError {
fn _description(&self) -> &str {
match *self {
ParseError::InvalidCharacter { .. } => "invalid character",
ParseError::InvalidGroupCount { .. } => "invalid number of groups",
ParseError::InvalidGroupLength { .. } => "invalid group length",
ParseError::InvalidLength { .. } => "invalid length",
}
}
}
pub(crate) fn len_matches_any(len: usize, crits: &[usize]) -> bool {
for crit in crits {
if len == *crit {
return true;
}
}
false
}
#[allow(dead_code)]
pub(crate) fn len_matches_range(len: usize, min: usize, max: usize) -> bool {
for crit in min..(max + 1) {
if len == crit {
return true;
}
}
false
}
pub(crate) const ACC_GROUP_LENS: [usize; 5] = [8, 12, 16, 20, 32];
pub(crate) const GROUP_LENS: [usize; 5] = [8, 4, 4, 4, 12];