simplify StackNode
deserialisation
This commit is contained in:
parent
f27e9625e8
commit
75d68e54ba
@ -54,6 +54,12 @@ pub enum StackParseError<ElementParseError: Error> {
|
|||||||
Element(ElementParseError),
|
Element(ElementParseError),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl<E: Error> From<PointParseError> for StackParseError<E> {
|
||||||
|
fn from(value: PointParseError) -> Self {
|
||||||
|
Self::Point(value)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl<ElementParseError: Error> Display for StackParseError<ElementParseError> {
|
impl<ElementParseError: Error> Display for StackParseError<ElementParseError> {
|
||||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||||
match self {
|
match self {
|
||||||
@ -75,9 +81,7 @@ impl<'a, Ctx: Context<'a>, F: Factory<'a, Ctx>> Factory<'a, Ctx> for StackNodeFa
|
|||||||
type ParseError = StackParseError<ParseError<'a, Ctx, F>>;
|
type ParseError = StackParseError<ParseError<'a, Ctx, F>>;
|
||||||
|
|
||||||
fn deserialize(&self, inctx: impl InCtx<'a, Ctx>) -> ParseResult<'a, Ctx, Self> {
|
fn deserialize(&self, inctx: impl InCtx<'a, Ctx>) -> ParseResult<'a, Ctx, Self> {
|
||||||
let (rest, inctx) = NullableFactory::new(self.clone())
|
let (rest, inctx) = NullableFactory::new(self.clone()).ideserialize(inctx)?;
|
||||||
.ideserialize(inctx)
|
|
||||||
.map_err(StackParseError::Point)?;
|
|
||||||
let element = self
|
let element = self
|
||||||
.element_factory
|
.element_factory
|
||||||
.deserialize(inctx)
|
.deserialize(inctx)
|
||||||
@ -169,9 +173,7 @@ impl<'a, Ctx: Context<'a>, F: InlineableFactory<'a, Ctx>> InlineableFactory<'a,
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn ideserialize<I: InCtx<'a, Ctx>>(&self, inctx: I) -> IParseResult<'a, Ctx, Self, I> {
|
fn ideserialize<I: InCtx<'a, Ctx>>(&self, inctx: I) -> IParseResult<'a, Ctx, Self, I> {
|
||||||
let (rest, inctx) = NullableFactory::new(self.clone())
|
let (rest, inctx) = NullableFactory::new(self.clone()).ideserialize(inctx)?;
|
||||||
.ideserialize(inctx)
|
|
||||||
.map_err(StackParseError::Point)?;
|
|
||||||
let (element, inctx) = self
|
let (element, inctx) = self
|
||||||
.element_factory
|
.element_factory
|
||||||
.ideserialize(inctx)
|
.ideserialize(inctx)
|
||||||
|
Loading…
Reference in New Issue
Block a user