loosen StaticPair
bounds
This commit is contained in:
parent
d75e7c05a8
commit
434a267507
@ -34,9 +34,9 @@ pub trait StaticPair<'a, Ctx: Context<'a>>:
|
|||||||
/// [Factory] data. May, depending on the usecase, include factory (factories) on the element(s).
|
/// [Factory] data. May, depending on the usecase, include factory (factories) on the element(s).
|
||||||
type FactoryData: 'a + Send + Sync + Clone;
|
type FactoryData: 'a + Send + Sync + Clone;
|
||||||
/// First element's type. Must equal [`StaticPairSerializable::SA`].
|
/// First element's type. Must equal [`StaticPairSerializable::SA`].
|
||||||
type A: MentionableBase<'a, Ctx, Fctr = Self::FA> + MentionableTop<'a, Ctx>;
|
type A: MentionableBase<'a, Ctx, Fctr = Self::FA>;
|
||||||
/// Second element's type. Must equal [`StaticPairSerializable::SB`].
|
/// Second element's type. Must equal [`StaticPairSerializable::SB`].
|
||||||
type B: MentionableBase<'a, Ctx, Fctr = Self::FB> + MentionableTop<'a, Ctx>;
|
type B: MentionableBase<'a, Ctx, Fctr = Self::FB>;
|
||||||
/// First element's factory.
|
/// First element's factory.
|
||||||
type FA: FactoryBase<'a, Ctx, Mtbl = Self::A> + InlineableFactory<'a, Ctx>;
|
type FA: FactoryBase<'a, Ctx, Mtbl = Self::A> + InlineableFactory<'a, Ctx>;
|
||||||
/// Second element's factory.
|
/// Second element's factory.
|
||||||
@ -112,8 +112,10 @@ impl<'a, Ctx: Context<'a>, SP: StaticPair<'a, Ctx>> MentionableBase<'a, Ctx>
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a, Ctx: Context<'a>, SP: StaticPair<'a, Ctx>> MentionableTop<'a, Ctx>
|
impl<'a, Ctx: Context<'a>, SP: StaticPair<'a, Ctx>> MentionableTop<'a, Ctx> for StaticPairObject<SP>
|
||||||
for StaticPairObject<SP>
|
where
|
||||||
|
SP::A: MentionableTop<'a, Ctx>,
|
||||||
|
SP::B: MentionableTop<'a, Ctx>,
|
||||||
{
|
{
|
||||||
fn points_typed(&self, points: &mut impl PointsVisitor<'a, Ctx>) {
|
fn points_typed(&self, points: &mut impl PointsVisitor<'a, Ctx>) {
|
||||||
let (a, b) = self.pair.elements();
|
let (a, b) = self.pair.elements();
|
||||||
@ -153,7 +155,7 @@ where
|
|||||||
.ideserialize(inctx)
|
.ideserialize(inctx)
|
||||||
.map_err(|e| SP::from_error_a(&self.factory_data, e))?;
|
.map_err(|e| SP::from_error_a(&self.factory_data, e))?;
|
||||||
let b = fb
|
let b = fb
|
||||||
.deserialize(inctx)
|
.rdeserialize(inctx)
|
||||||
.map_err(|e| SP::from_error_b(&self.factory_data, e))?;
|
.map_err(|e| SP::from_error_b(&self.factory_data, e))?;
|
||||||
Ok(StaticPairObject {
|
Ok(StaticPairObject {
|
||||||
pair: SP::from_parsed(&self.factory_data, a, b),
|
pair: SP::from_parsed(&self.factory_data, a, b),
|
||||||
@ -163,7 +165,7 @@ where
|
|||||||
fn rextend(&self, mentionable: Self::Mtbl, tail: &[u8]) -> ParseResult<'a, Ctx, Self> {
|
fn rextend(&self, mentionable: Self::Mtbl, tail: &[u8]) -> ParseResult<'a, Ctx, Self> {
|
||||||
let (_, fb) = SP::factories(&self.factory_data);
|
let (_, fb) = SP::factories(&self.factory_data);
|
||||||
let (a, b) = mentionable.pair.into_elements();
|
let (a, b) = mentionable.pair.into_elements();
|
||||||
match fb.extend(b, tail) {
|
match fb.rextend(b, tail) {
|
||||||
Ok(b) => Ok(SP::from_parsed(&self.factory_data, a, b).into()),
|
Ok(b) => Ok(SP::from_parsed(&self.factory_data, a, b).into()),
|
||||||
Err(e) => Err(SP::from_error_b(&self.factory_data, e)),
|
Err(e) => Err(SP::from_error_b(&self.factory_data, e)),
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user