scsys_core/cont/traits/
raw_container.rs1pub trait RawContainer {
9 type Item;
10
11 private!();
12}
13
14#[cfg(feature = "alloc")]
18impl<T> RawContainer for alloc::boxed::Box<dyn RawContainer<Item = T>> {
19 type Item = T;
20
21 seal!();
22}
23
24macro_rules! impl_raw_container {
25 (@impl $($p:ident)::*<$K:ident, $V:ident, $($rest:ident),*>) => {
26 impl<$K, $V, $($rest),*> RawContainer for $($p)::*<$K, $V, $($rest),*> {
27 type Item = $V;
28
29 seal!();
30 }
31 };
32 (@impl $($p:ident)::*<$K:ident, $V:ident>) => {
33 impl<$K, $V> RawContainer for $($p)::*<$K, $V> {
34 type Item = $V;
35
36 seal!();
37 }
38 };
39 (@impl $($p:ident)::*<$I:ident>) => {
40 impl<$I> RawContainer for $($p)::*<$I> {
41 type Item = $I;
42
43 seal!();
44 }
45 };
46 ($($($p:ident)::*<$($T:ident),*>),* $(,)?) => {
47 $(
48 impl_raw_container!(@impl $($p)::*<$($T),*>);
49 )*
50 };
51}
52
53impl_raw_container! {
54 Option<T>,
55 core::cell::Cell<T>,
56 core::cell::RefCell<T>,
57 core::marker::PhantomData<T>,
58}
59
60#[cfg(feature = "alloc")]
61impl_raw_container! {
62 alloc::boxed::Box<T>,
63 alloc::collections::BTreeMap<K, V>,
64 alloc::collections::BTreeSet<T>,
65 alloc::collections::VecDeque<T>,
66 alloc::sync::Arc<T>,
67 alloc::vec::Vec<T>,
68}
69
70#[cfg(feature = "std")]
71impl_raw_container! {
72 std::collections::HashMap<K, V, S>,
73 std::sync::Mutex<T>,
74}
75
76#[cfg(feature = "std")]
77impl<K, S> RawContainer for std::collections::HashSet<K, S> {
78 type Item = K;
79
80 seal!();
81}
82
83impl<T> RawContainer for [T] {
84 type Item = T;
85
86 seal!();
87}
88
89impl<T> RawContainer for &[T] {
90 type Item = T;
91
92 seal!();
93}
94
95impl<T> RawContainer for &mut [T] {
96 type Item = T;
97
98 seal!();
99}
100
101impl<T, const N: usize> RawContainer for [T; N] {
102 type Item = T;
103
104 seal!();
105}
106
107impl<T, const N: usize> RawContainer for &[T; N] {
108 type Item = T;
109
110 seal!();
111}
112
113impl<T, const N: usize> RawContainer for &mut [T; N] {
114 type Item = T;
115
116 seal!();
117}
118
119#[allow(unused_macros)]
120macro_rules! tuple_cont {
121 ($($T:ident),+ $(,)?) => {
122 impl<$($T),+> RawContainer for ($($T,)+) {
123 type Item = ($($T,)+);
124
125 seal!();
126 }
127 };
128}
129
130impl<T> RawContainer for (T,) {
131 type Item = T;
132
133 seal!();
134}
135
136impl<T> RawContainer for (T, T) {
137 type Item = T;
138
139 seal!();
140}
141
142impl<T> RawContainer for (T, T, T) {
143 type Item = T;
144
145 seal!();
146}