harper_core/patterns/
modal_verb.rs

1use super::{Pattern, WordSet};
2
3pub struct ModalVerb {
4    inner: WordSet,
5}
6
7impl Default for ModalVerb {
8    fn default() -> Self {
9        let modals = [
10            "can", "could", "may", "might", "must", "shall", "should", "will", "would", "ought",
11            "dare",
12        ];
13        let mut words = WordSet::new(&modals);
14        modals.iter().for_each(|word| {
15            words.add(&format!("{word}n't"));
16        });
17
18        Self { inner: words }
19    }
20}
21
22impl Pattern for ModalVerb {
23    fn matches(&self, tokens: &[crate::Token], source: &[char]) -> Option<usize> {
24        self.inner.matches(tokens, source)
25    }
26}