Representation always exists
This commit is contained in:
parent
0829b16fc9
commit
4818b23c3b
@ -8,7 +8,7 @@ where
|
||||
{
|
||||
inner: P,
|
||||
name: Option<String>,
|
||||
repr: Option<Representation>,
|
||||
repr: Representation,
|
||||
phantom: PhantomData<(I, O, E)>,
|
||||
}
|
||||
|
||||
@ -24,7 +24,7 @@ where
|
||||
self.name.clone()
|
||||
}
|
||||
|
||||
fn representation(&self) -> Option<Representation> {
|
||||
fn representation(&self) -> Representation {
|
||||
self.repr.clone()
|
||||
}
|
||||
}
|
||||
@ -37,7 +37,7 @@ where
|
||||
Self {
|
||||
inner,
|
||||
name: None,
|
||||
repr: None,
|
||||
repr: Representation::new(),
|
||||
phantom: PhantomData,
|
||||
}
|
||||
}
|
||||
@ -50,9 +50,6 @@ where
|
||||
}
|
||||
|
||||
pub fn with_repr(self, repr: Representation) -> Self {
|
||||
Self {
|
||||
repr: Some(repr),
|
||||
..self
|
||||
}
|
||||
Self { repr, ..self }
|
||||
}
|
||||
}
|
||||
|
@ -7,8 +7,8 @@ pub trait Parser<I, O, E> {
|
||||
fn name(&self) -> Option<String> {
|
||||
None
|
||||
}
|
||||
fn representation(&self) -> Option<Representation> {
|
||||
None
|
||||
fn representation(&self) -> Representation {
|
||||
Representation::new()
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -72,7 +72,7 @@ mod tests {
|
||||
let parser = literal_char('f');
|
||||
assert_eq!(Ok(('f', "unky")), parser.parse("funky"));
|
||||
|
||||
let repr = parser.representation().unwrap();
|
||||
let repr = parser.representation();
|
||||
assert!(matches!(repr.production(), EBNF::CharTerminal('f')));
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user