rspace_traits/
container.rs

1/*
2    Appellation: container <module>
3    Created At: 2025.12.29:14:39:20
4    Contrib: @FL03
5*/
6use crate::{Apply, 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 ContainerMap<T>: Container<T>
18where
19    Self::Cont<T>: RawSpace<Elem = T>,
20{
21    fn map<F, X>(&self, f: F) -> Self::Cont<X>
22    where
23        Self::Cont<T>: Apply<F, Output = Self::Cont<X>>,
24        Self::Cont<X>: Sized;
25}
26
27/// The [`ContainerIter`] trait extends the [`Container`] trait to provide an interface
28/// for obtaining iterators over the elements of the container.
29pub trait ContainerIter<U>: Container<U>
30where
31    Self::Cont<U>: RawSpace<Elem = U>,
32{
33    type Iter<'a, T>: Iterator<Item = &'a T>
34    where
35        Self: 'a,
36        T: 'a;
37
38    fn iter(&self) -> Self::Iter<'_, U>;
39}