rspace_traits/
container.rs

1/*
2    Appellation: store <module>
3    Created At: 2025.12.26:14:12:46
4    Contrib: @FL03
5*/
6use crate::space::RawSpace;
7
8/// The [`Container`] trait is a higher-kinded trait used to establish an interface for
9/// defining containers themselves.
10pub trait Container<U>
11where
12    Self::Cont<U>: RawSpace<Elem = U>,
13{
14    type Cont<V>: ?Sized;
15}
16
17pub trait ContainerIter<U>: Container<U>
18where
19    Self::Cont<U>: RawSpace<Elem = U>,
20{
21    type Iter<'a, T>: Iterator<Item = &'a T>
22    where
23        Self: 'a,
24        T: 'a;
25}
26
27/*
28 ************* Implementations *************
29*/
30#[allow(unused_macros)]
31macro_rules! container {
32    (@impl $trait:ident<$T:ident> for $($cont:ident)::*<$($U:ident),+ $(,)?>) => {
33        paste::paste! {
34            impl<$($U),+> $trait<$T> for $($cont)::*<$($U),+> {
35                type Cont<[<_ $T>]> = $($cont)::*<[<_ $T>]>;
36            }
37
38        }
39    };
40    (impl $trait:ident<$T:ident> for {$($($cont:ident)::*<$($U:ident),+ $(,)?>),* $(,)?}) => {
41        $(container!{ @impl $trait<$T> for $($cont)::*<$($U),+>})*
42    };
43}