rune/parse/
peek.rs

1use crate::alloc::Box;
2use crate::parse::{Parse, Peeker};
3
4/// Implemented by tokens that can be peeked for.
5pub trait Peek {
6    /// Peek the parser for the given token.
7    fn peek(p: &mut Peeker<'_>) -> bool;
8}
9
10/// Peek implementation for something that is boxed.
11impl<T> Peek for Box<T>
12where
13    T: Peek,
14{
15    #[inline]
16    fn peek(p: &mut Peeker<'_>) -> bool {
17        T::peek(p)
18    }
19}
20
21impl<A, B> Peek for (A, B)
22where
23    A: Parse + Peek,
24    B: Parse,
25{
26    #[inline]
27    fn peek(p: &mut Peeker<'_>) -> bool {
28        A::peek(p)
29    }
30}