use core::fmt::{
Debug,
Display,
Formatter,
};
#[derive(Debug, Clone, PartialEq, Eq)]
pub enum BaseAtom<T: 'static> {
Is {
t: Option<T>,
expect: T,
},
IsNot {
t: Option<T>,
not_expect: T,
},
NoneOf {
not_expected: &'static [T],
found: Option<T>,
},
OneOf {
expected: &'static [T],
found: Option<T>,
},
Tag {
tag: &'static str,
},
TagNoCase {
tag: &'static str,
},
List {
list: &'static [T],
},
Ascii {
found: u8,
expected: &'static str,
},
Utf8 {},
}
impl<T: Display + Debug> Display for BaseAtom<T> {
fn fmt(&self, f: &mut Formatter<'_>) -> core::fmt::Result {
match self {
BaseAtom::Is { t, expect } => write!(f, "Is: {:?} != {}", t, expect),
BaseAtom::IsNot { t, not_expect } => write!(f, "IsNot: {:?} != {}", t, not_expect),
BaseAtom::NoneOf {
not_expected,
found,
} => write!(f, "NoneOf: not expect {:?} found {:?}", not_expected, found),
BaseAtom::OneOf { expected, found } => {
write!(f, "OneOf: expect {:?} found {:?}", expected, found)
}
BaseAtom::Tag { tag } => write!(f, "Tag: {:?}", tag),
BaseAtom::TagNoCase { tag } => {
write!(f, "TagNoCase: {:?}", tag)
}
BaseAtom::List { list } => write!(f, "List: {:?}", list),
BaseAtom::Ascii { found, expected } => {
write!(f, "DigitAtom: Found {} Expected {}", found, expected)
}
BaseAtom::Utf8 {} => {
write!(f, "Utf8")
}
}
}
}