mipl 0.2.1

Minimal Imperative Parsing Library
Documentation
use super::*;

/// Match a specific string.
pub struct ExactMatch {
    /// The string to match to.
    pub matches: String
}
impl Peeker for ExactMatch {
    type Item = String;

    fn peek_for_token(&self, parser: &mut Parser) -> Option<Token> {
        if let Some(tok) = parser.peek() {
            match &tok {
                Token::Str(s) => {
                    if *s == self.matches {
                        Some(tok)
                    } else {
                        None
                    }
                },
                _ => None
            }
        } else {
            None
        }
    }
}
impl ContainerCp for ExactMatch {
    type Input = String;
    type ContainedType = String;

    fn new_contained(value: Self::Input) -> Self::ContainedType {
        value
    }
    fn new(value: Self::Input) -> Self {
        ExactMatch { matches: Self::new_contained(value) }
    }
}