diff --git a/src/atomic.rs b/src/atomic.rs index e588810..8944375 100644 --- a/src/atomic.rs +++ b/src/atomic.rs @@ -29,7 +29,7 @@ pub type AParseError = ::AParseError; pub type AParseResult = Result>; /// [`Atomic`] base. -pub trait AtomicBase: 'static + Send + Sync + Send + Clone + Serializable { +pub trait AtomicBase: 'static + Send + Sync + Clone + Serializable { /// Equivalent of [`FactoryBase::ParseError`]. /// /// [`FactoryBase::ParseError`]: crate::rcore::FactoryBase::ParseError diff --git a/src/rstd/inlining/static_pair.rs b/src/rstd/inlining/static_pair.rs index 55c9b81..08ed414 100644 --- a/src/rstd/inlining/static_pair.rs +++ b/src/rstd/inlining/static_pair.rs @@ -68,6 +68,7 @@ pub trait StaticPair<'a, Ctx: Context<'a>>: } /// Generic implementation of a [Mentionable] for [StaticPair]s. +#[derive(Clone)] pub struct StaticPairObject { pair: SP, } @@ -205,3 +206,24 @@ where { const SIZE: usize = SP::FA::SIZE + SP::FB::SIZE; } + +pub trait StaticPairAtomic: + 'static + Send + Sync + Clone + Sized + StaticPairSerializable +{ + /// First element's type. Must equal [`StaticPairSerializable::SA`]. + type A: AtomicBase; + /// Second element's type. Must equal [`StaticPairSerializable::SB`]. + type B: AtomicBase; + + type AParseError: Error; + /// Construct the atomic from the elements. + fn from_parsed(a: Self::A, b: Self::B) -> Result; + /// Regularise the error returned while parsing the first element. + fn from_error_a(error: AParseError) -> Self::AParseError; + /// Regularise the error returned while parsing the second element. + fn from_error_b(error: AParseError) -> Self::AParseError; +} + +impl AtomicBase for StaticPairObject { + type AParseError = SP::AParseError; +}