use core::fmt;
#[non_exhaustive]
#[derive(Clone, Copy, PartialEq, Eq, Hash, Debug)]
pub enum UnterminatedKind {
BlockComment,
StringLiteral,
}
impl fmt::Display for UnterminatedKind {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
UnterminatedKind::BlockComment => f.write_str("block comment"),
UnterminatedKind::StringLiteral => f.write_str("string literal"),
}
}
}
impl core::error::Error for UnterminatedKind {}
#[derive(Clone, Copy, PartialEq, Eq, Debug)]
pub struct Unterminated {
pub kind: UnterminatedKind,
pub offset: usize,
}
impl fmt::Display for Unterminated {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(
f,
"unterminated {} opened at byte {}",
self.kind, self.offset
)
}
}
impl core::error::Error for Unterminated {}