remove Pair

This commit is contained in:
AF 2023-06-28 13:00:38 +00:00
parent 0e8dddfa21
commit bfff862b03

View File

@ -6,25 +6,19 @@ use std::fmt::Display;
use crate::rcore::*;
use crate::rstd::inlining::{static_pair::*, *};
#[derive(Clone)]
pub struct Pair<A, B> {
pub a: A,
pub b: B,
}
pub type PairObject<A, B> = StaticPairObject<(A, B)>;
pub type PairFactory<'a, Ctx, A, B> = StaticPairFactory<'a, Ctx, (A, B)>;
pub type PairObject<A, B> = StaticPairObject<Pair<A, B>>;
pub type PairFactory<'a, Ctx, A, B> = StaticPairFactory<'a, Ctx, Pair<A, B>>;
impl<A: Serializable, B: Serializable> StaticPairSerializable for Pair<A, B> {
impl<A: Serializable, B: Serializable> 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<ErrorA: Error, ErrorB: Error> Display for PairParseError<ErrorA, ErrorB> {
impl<ErrorA: Error, ErrorB: Error> Error for PairParseError<ErrorA, ErrorB> {}
impl<'a, Ctx: Context<'a>, A: Mentionable<'a, Ctx>, B: Mentionable<'a, Ctx>> StaticPair<'a, Ctx>
for Pair<A, B>
for (A, B)
where
A::Fctr: InlineableFactory<'a, Ctx>,
{
type FactoryData = Pair<Self::FA, Self::FB>;
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, A::Fctr>, 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())
}
}