simplify NullableFactory::deserialize

This commit is contained in:
AF 2023-06-30 23:14:58 +00:00
parent b0077e0756
commit 540fdce02a

View File

@ -56,13 +56,7 @@ impl<'a, Ctx: Context<'a>, F: Factory<'a, Ctx>> Factory<'a, Ctx> for NullableFac
type ParseError = PointParseError;
fn deserialize(&self, inctx: impl InCtx<'a, Ctx>) -> ParseResult<'a, Ctx, Self> {
let factory = self.factory.clone();
let (address, inctx) = inctx.icnext_address(|slice| PointParseError::from(slice))?;
Ok(if address.point == HASH_ZEROS {
Nullable::Null(factory)
} else {
Nullable::NotNull(Point::from_address(address, factory, inctx.iresolver()))
})
self.ideserialize(inctx).seal()
}
fn extend(&self, _mentionable: Self::Mtbl, tail: &[u8]) -> ParseResult<'a, Ctx, Self> {