diff --git a/src/annotated.rs b/src/annotated.rs index cbcf189..c57ca6c 100644 --- a/src/annotated.rs +++ b/src/annotated.rs @@ -8,7 +8,7 @@ where { inner: P, name: Option, - repr: Option, + repr: Representation, phantom: PhantomData<(I, O, E)>, } @@ -24,7 +24,7 @@ where self.name.clone() } - fn representation(&self) -> Option { + 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 } } } diff --git a/src/parser.rs b/src/parser.rs index 27fb9f7..3fa8a17 100644 --- a/src/parser.rs +++ b/src/parser.rs @@ -7,8 +7,8 @@ pub trait Parser { fn name(&self) -> Option { None } - fn representation(&self) -> Option { - None + fn representation(&self) -> Representation { + Representation::new() } } diff --git a/src/primitives.rs b/src/primitives.rs index c3c92ca..7fb1243 100644 --- a/src/primitives.rs +++ b/src/primitives.rs @@ -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'))); } }