From 75d68e54ba0aae79cec33181c3b9c574822a0c61 Mon Sep 17 00:00:00 2001 From: timofey Date: Fri, 30 Jun 2023 23:09:57 +0000 Subject: [PATCH] simplify `StackNode` deserialisation --- src/rstd/collections/stack.rs | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/rstd/collections/stack.rs b/src/rstd/collections/stack.rs index 4836e44..27e859b 100644 --- a/src/rstd/collections/stack.rs +++ b/src/rstd/collections/stack.rs @@ -54,6 +54,12 @@ pub enum StackParseError { Element(ElementParseError), } +impl From for StackParseError { + fn from(value: PointParseError) -> Self { + Self::Point(value) + } +} + impl Display for StackParseError { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { match self { @@ -75,9 +81,7 @@ impl<'a, Ctx: Context<'a>, F: Factory<'a, Ctx>> Factory<'a, Ctx> for StackNodeFa type ParseError = StackParseError>; fn deserialize(&self, inctx: impl InCtx<'a, Ctx>) -> ParseResult<'a, Ctx, Self> { - let (rest, inctx) = NullableFactory::new(self.clone()) - .ideserialize(inctx) - .map_err(StackParseError::Point)?; + let (rest, inctx) = NullableFactory::new(self.clone()).ideserialize(inctx)?; let element = self .element_factory .deserialize(inctx) @@ -169,9 +173,7 @@ impl<'a, Ctx: Context<'a>, F: InlineableFactory<'a, Ctx>> InlineableFactory<'a, } fn ideserialize>(&self, inctx: I) -> IParseResult<'a, Ctx, Self, I> { - let (rest, inctx) = NullableFactory::new(self.clone()) - .ideserialize(inctx) - .map_err(StackParseError::Point)?; + let (rest, inctx) = NullableFactory::new(self.clone()).ideserialize(inctx)?; let (element, inctx) = self .element_factory .ideserialize(inctx)