harper_core/patterns/
inflection_of_be.rs

1use super::SingleTokenPattern;
2use crate::Token;
3use crate::patterns::WordSet;
4
5/// Matches any inflection of the verb “be”:
6/// `am`, `is`, `are`, `was`, `were`, `be`, `been`, `being`.
7pub struct InflectionOfBe {
8    /// If using a `WordSet` proves expensive, we'll switch to something else.
9    inner: WordSet,
10}
11
12impl Default for InflectionOfBe {
13    fn default() -> Self {
14        Self::new()
15    }
16}
17
18impl InflectionOfBe {
19    pub fn new() -> Self {
20        Self {
21            inner: WordSet::new(&["be", "am", "is", "are", "was", "were", "been", "being"]),
22        }
23    }
24}
25
26impl SingleTokenPattern for InflectionOfBe {
27    fn matches_token(&self, token: &Token, source: &[char]) -> bool {
28        self.inner.matches_token(token, source)
29    }
30}