reorder stack definitions
This commit is contained in:
parent
f2ff6b8e9d
commit
6935b072dd
@ -130,6 +130,43 @@ where
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a, Ctx: Context<'a>, F: Factory<'a, Ctx> + InliningFactory<'a, Ctx>> CInliningFactory<'a, Ctx>
|
||||
for StackNodeFactory<F>
|
||||
where
|
||||
F::Mtbl: MentionableTop<'a, Ctx>,
|
||||
{
|
||||
fn cextension_error(&self, tail: &[u8]) -> Self::ParseError {
|
||||
StackParseError::Element(self.element_factory.extension_error(tail))
|
||||
}
|
||||
|
||||
fn cideserialize<I: InCtx<'a, Ctx>>(&self, inctx: I) -> IParseResult<'a, Ctx, Self, I> {
|
||||
let (rest, inctx) = self.parse_point(inctx)?;
|
||||
let (element, inctx) = self
|
||||
.element_factory
|
||||
.ideserialize(inctx)
|
||||
.map_err(StackParseError::Element)?;
|
||||
Ok((StackNode { rest, element }, inctx))
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a, Ctx: Context<'a>, F: Factory<'a, Ctx> + FixedSizeFactory<'a, Ctx>>
|
||||
FixedSizeFactory<'a, Ctx> for StackNodeFactory<F>
|
||||
where
|
||||
F::Mtbl: MentionableTop<'a, Ctx>,
|
||||
{
|
||||
fn size(&self) -> usize {
|
||||
Stack::<'a, Ctx, F::Mtbl>::SIZE + self.element_factory.size()
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a, Ctx: Context<'a>, F: Factory<'a, Ctx> + ConstSizeFactory<'a, Ctx>>
|
||||
ConstSizeFactory<'a, Ctx> for StackNodeFactory<F>
|
||||
where
|
||||
F::Mtbl: MentionableTop<'a, Ctx>,
|
||||
{
|
||||
const SIZE: usize = Stack::<'a, Ctx, F::Mtbl>::SIZE + F::SIZE;
|
||||
}
|
||||
|
||||
/// See [`StackVecResult`].
|
||||
pub type StackFaiure<'a, Ctx, A> = ResolutionFailure<'a, Ctx, StackNode<'a, Ctx, A>>;
|
||||
|
||||
@ -206,43 +243,6 @@ where
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a, Ctx: Context<'a>, F: Factory<'a, Ctx> + InliningFactory<'a, Ctx>> CInliningFactory<'a, Ctx>
|
||||
for StackNodeFactory<F>
|
||||
where
|
||||
F::Mtbl: MentionableTop<'a, Ctx>,
|
||||
{
|
||||
fn cextension_error(&self, tail: &[u8]) -> Self::ParseError {
|
||||
StackParseError::Element(self.element_factory.extension_error(tail))
|
||||
}
|
||||
|
||||
fn cideserialize<I: InCtx<'a, Ctx>>(&self, inctx: I) -> IParseResult<'a, Ctx, Self, I> {
|
||||
let (rest, inctx) = self.parse_point(inctx)?;
|
||||
let (element, inctx) = self
|
||||
.element_factory
|
||||
.ideserialize(inctx)
|
||||
.map_err(StackParseError::Element)?;
|
||||
Ok((StackNode { rest, element }, inctx))
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a, Ctx: Context<'a>, F: Factory<'a, Ctx> + FixedSizeFactory<'a, Ctx>>
|
||||
FixedSizeFactory<'a, Ctx> for StackNodeFactory<F>
|
||||
where
|
||||
F::Mtbl: MentionableTop<'a, Ctx>,
|
||||
{
|
||||
fn size(&self) -> usize {
|
||||
Stack::<'a, Ctx, F::Mtbl>::SIZE + self.element_factory.size()
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a, Ctx: Context<'a>, F: Factory<'a, Ctx> + ConstSizeFactory<'a, Ctx>>
|
||||
ConstSizeFactory<'a, Ctx> for StackNodeFactory<F>
|
||||
where
|
||||
F::Mtbl: MentionableTop<'a, Ctx>,
|
||||
{
|
||||
const SIZE: usize = Stack::<'a, Ctx, F::Mtbl>::SIZE + F::SIZE;
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use std::rc::Rc;
|
||||
|
Loading…
Reference in New Issue
Block a user