use super::*;
use std::collections::HashSet;
pub struct OrExactMatch {
matches: HashSet<String>
}
impl Peeker for OrExactMatch {
type Item = String;
fn peek_for_token(&self, parser: &mut Parser) -> Option<Token> {
if let Token::Str(s) = parser.peek()? {
if self.matches.contains(&s) {
Some(Token::Str(s))
} else {
None
}
} else {
None
}
}
}
impl IsContainerCpInput for Vec<String> {}
impl ContainedType for HashSet<String> {}
impl ContainerCp for OrExactMatch {
type ContainedType = HashSet<String>;
type Input = Vec<String>;
fn new_contained(value: Self::Input) -> Self::ContainedType {
HashSet::from_iter(value)
}
fn new(value: Self::Input) -> Self {
OrExactMatch { matches: Self::new_contained(value) }
}
}