litcheck_filecheck/pattern/matcher/matchers/
always.rs

1use crate::common::*;
2
3/// This matcher always succeeds
4#[derive(Debug)]
5pub struct AlwaysMatch {
6    span: SourceSpan,
7}
8impl AlwaysMatch {
9    pub const fn new(span: SourceSpan) -> Self {
10        Self { span }
11    }
12}
13impl MatcherMut for AlwaysMatch {
14    #[inline]
15    fn try_match_mut<'input, 'context, C>(
16        &self,
17        input: Input<'input>,
18        context: &mut C,
19    ) -> DiagResult<MatchResult<'input>>
20    where
21        C: Context<'input, 'context> + ?Sized,
22    {
23        self.try_match(input, context)
24    }
25}
26impl Matcher for AlwaysMatch {
27    #[inline]
28    fn try_match<'input, 'context, C>(
29        &self,
30        input: Input<'input>,
31        _context: &C,
32    ) -> DiagResult<MatchResult<'input>>
33    where
34        C: Context<'input, 'context> + ?Sized,
35    {
36        Ok(MatchResult::ok(MatchInfo::new(
37            input.start()..input.start(),
38            self.span,
39        )))
40    }
41}
42impl Spanned for AlwaysMatch {
43    #[inline]
44    fn span(&self) -> SourceSpan {
45        self.span
46    }
47}