use flatcontainer::{Push, Region, ReserveItems};
pub trait MzRegionPreference: 'static {
type Owned;
type Region: for<'a> Region<Owned = Self::Owned>
+ Push<Self::Owned>
+ for<'a> Push<<Self::Region as Region>::ReadItem<'a>>
+ for<'a> ReserveItems<<Self::Region as Region>::ReadItem<'a>>;
}
#[derive(Debug)]
pub struct OwnedRegionOpinion<T>(std::marker::PhantomData<T>);
mod tuple {
use flatcontainer::impls::tuple::*;
use paste::paste;
use crate::flatcontainer::MzRegionPreference;
macro_rules! tuple_flatcontainer {
($($name:ident)+) => (
paste! {
impl<$($name: MzRegionPreference),*> MzRegionPreference for ($($name,)*) {
type Owned = ($($name::Owned,)*);
type Region = [<Tuple $($name)* Region >]<$($name::Region,)*>;
}
}
)
}
tuple_flatcontainer!(A);
tuple_flatcontainer!(A B);
tuple_flatcontainer!(A B C);
tuple_flatcontainer!(A B C D);
tuple_flatcontainer!(A B C D E);
}
mod copy {
use flatcontainer::MirrorRegion;
use crate::flatcontainer::MzRegionPreference;
macro_rules! implement_for {
($index_type:ty) => {
impl MzRegionPreference for $index_type {
type Owned = Self;
type Region = MirrorRegion<Self>;
}
};
}
implement_for!(());
implement_for!(bool);
implement_for!(char);
implement_for!(u8);
implement_for!(u16);
implement_for!(u32);
implement_for!(u64);
implement_for!(u128);
implement_for!(usize);
implement_for!(i8);
implement_for!(i16);
implement_for!(i32);
implement_for!(i64);
implement_for!(i128);
implement_for!(isize);
implement_for!(f32);
implement_for!(f64);
implement_for!(std::num::Wrapping<i8>);
implement_for!(std::num::Wrapping<i16>);
implement_for!(std::num::Wrapping<i32>);
implement_for!(std::num::Wrapping<i64>);
implement_for!(std::num::Wrapping<i128>);
implement_for!(std::num::Wrapping<isize>);
implement_for!(std::time::Duration);
}
mod vec {
use flatcontainer::OwnedRegion;
use crate::flatcontainer::{MzRegionPreference, OwnedRegionOpinion};
impl<T: Clone + 'static> MzRegionPreference for OwnedRegionOpinion<Vec<T>> {
type Owned = Vec<T>;
type Region = OwnedRegion<T>;
}
}
impl<T: MzRegionPreference> MzRegionPreference for Option<T> {
type Owned = <flatcontainer::OptionRegion<T::Region> as Region>::Owned;
type Region = flatcontainer::OptionRegion<T::Region>;
}