diff --git a/src/rstd/collections/pair.rs b/src/rstd/collections/pair.rs index 0724178..f3f832a 100644 --- a/src/rstd/collections/pair.rs +++ b/src/rstd/collections/pair.rs @@ -6,25 +6,19 @@ use std::fmt::Display; use crate::rcore::*; use crate::rstd::inlining::{static_pair::*, *}; -#[derive(Clone)] -pub struct Pair { - pub a: A, - pub b: B, -} +pub type PairObject = StaticPairObject<(A, B)>; +pub type PairFactory<'a, Ctx, A, B> = StaticPairFactory<'a, Ctx, (A, B)>; -pub type PairObject = StaticPairObject>; -pub type PairFactory<'a, Ctx, A, B> = StaticPairFactory<'a, Ctx, Pair>; - -impl StaticPairSerializable for Pair { +impl StaticPairSerializable for (A, B) { type SA = A; type SB = B; fn elements(&self) -> (&Self::SA, &Self::SB) { - (&self.a, &self.b) + (&self.0, &self.1) } fn into_elements(self) -> (Self::SA, Self::SB) { - (self.a, self.b) + self } } @@ -50,11 +44,11 @@ impl Display for PairParseError { impl Error for PairParseError {} impl<'a, Ctx: Context<'a>, A: Mentionable<'a, Ctx>, B: Mentionable<'a, Ctx>> StaticPair<'a, Ctx> - for Pair + for (A, B) where A::Fctr: InlineableFactory<'a, Ctx>, { - type FactoryData = Pair; + type FactoryData = (Self::FA, Self::FB); type A = A; type B = B; type FA = A::Fctr; @@ -62,11 +56,11 @@ where type ParseError = PairParseError, ParseError<'a, Ctx, B::Fctr>>; fn factories(factory_data: &Self::FactoryData) -> (&Self::FA, &Self::FB) { - (&factory_data.a, &factory_data.b) + (&factory_data.0, &factory_data.1) } fn from_parsed(_factory_data: &Self::FactoryData, a: Self::A, b: Self::B) -> Self { - Pair { a, b } + (a, b) } fn from_error_a( @@ -84,9 +78,6 @@ where } fn factory_data(&self) -> Self::FactoryData { - Pair { - a: self.a.factory(), - b: self.b.factory(), - } + (self.0.factory(), self.1.factory()) } }