use core::marker::PhantomData;
use crate::{Buffer, Error, Tokenizer};
pub struct And<T, U, B> {
first: T,
second: U,
buffer: PhantomData<fn(B)>,
}
impl<T, U, B> Clone for And<T, U, B>
where
T: Clone,
U: Clone,
{
fn clone(&self) -> Self {
Self {
first: self.first.clone(),
second: self.second.clone(),
buffer: PhantomData,
}
}
}
impl<T, U, B> Copy for And<T, U, B>
where
T: Copy,
U: Copy,
{
}
impl<T, U, B> And<T, U, B> {
pub fn new(first: T, second: U) -> Self {
Self {
first,
second,
buffer: PhantomData,
}
}
}
impl<'input, T, U, B> Tokenizer<'input, B> for And<T, U, B>
where
T: Tokenizer<'input, B>,
U: Tokenizer<'input, B>,
B: Buffer<'input>,
{
type Token = (T::Token, U::Token);
fn to_token(&self, reader: &mut crate::Reader<'_, 'input, B>) -> Result<Self::Token, Error> {
reader.parse((&self.first, &self.second))
}
}