1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
use std::{
fmt::{
Debug,
Display,
Formatter,
Result as FmtResult,
},
marker::PhantomData,
};
#[derive(Debug)]
pub struct SequenceParserRequirement<'a, 'b, R1, R2>
where
R1: Debug + Display,
R2: Debug + Display,
{
first: R1,
second: R2,
_a: PhantomData<&'a ()>,
_b: PhantomData<&'b ()>,
}
impl<'a, 'b, R1, R2> SequenceParserRequirement<'a, 'b, R1, R2>
where
R1: Debug + Display,
R2: Debug + Display,
{
pub fn new(first: R1, second: R2) -> Self
{
Self {
first,
second,
_a: PhantomData,
_b: PhantomData,
}
}
pub fn first(&self) -> &R1
{
&self.first
}
pub fn second(&self) -> &R2
{
&self.second
}
}
impl<'a, 'b, R1, R2> Display for SequenceParserRequirement<'a, 'b, R1, R2>
where
R1: Debug + Display,
R2: Debug + Display,
{
fn fmt(&self, f: &mut Formatter) -> FmtResult
{
write!(f, "{} {}", self.first, self.second)
}
}