scsys_traits/
container.rs

1/*
2    Appellation: container <module>
3    Contrib: @FL03
4*/
5/// [`RawContainer`] defines a standard interface for all _containers_ that are used to store
6/// other entities.
7pub unsafe trait RawContainer<T> {
8    type Cont<V>;
9
10    private!();
11}
12
13/*
14 ************* Implementations *************
15*/
16
17macro_rules! impl_raw_container {
18    ($($($t:ident)::*<$T:ident>),* $(,)?) => {
19        $(
20            impl_raw_container!(@impl $($t)::*<$T>);
21        )*
22    };
23    (@impl $($t:ident)::*<$T:ident>) => {
24        unsafe impl<$T> RawContainer<T> for $($t)::*<$T> {
25            type Cont<V> = $($t)::*<V>;
26
27            seal!();
28        }
29    };
30}
31
32#[cfg(feature = "alloc")]
33impl_raw_container! {
34    alloc::vec::Vec<T>,
35    alloc::boxed::Box<T>,
36    alloc::rc::Rc<T>,
37    alloc::sync::Arc<T>,
38    alloc::collections::BTreeSet<T>,
39    alloc::collections::LinkedList<T>,
40}