1use crate::space::RawSpace;
7
8macro_rules! impl_raw_space {
9 (impl<Elem = $E:ident> $trait:ident for {$(
10 $($cont:ident)::*<$($lt:lifetime,)? $($T:ident),*> $({where $($rest:tt)*})?
11 ),* $(,)?}) => {
12 $(impl_raw_space! {
13 @impl<Elem = $E> $trait for $($cont)::*<$($lt,)? $($T),*> $(where $($rest)*)?
14 })*
15 };
16 (@impl<Elem = $E:ident> $trait:ident for $($cont:ident)::*<$($lt:lifetime,)? $($T:ident),*> $(where $($rest:tt)*)?) => {
17 impl<$($lt,)? $($T),*> $trait for $($cont)::*<$($lt,)? $($T),*> $(where $($rest)*)? {
18 type Elem = $E;
19 }
20 };
21}
22
23macro_rules! impl_raw_tuple_store {
24 (@impl<Elem = $E:ident> $trait:ident for ($($name:ident),+ $(,)?)) => {
25 impl<$E> $trait for ($($name),+) {
26 type Elem = $E;
27 }
28 };
29 (impl<Elem = $E:ident> $trait:ident for {$(($($name:ident),+)),* $(,)?}) => {
30 $(impl_raw_tuple_store! { @impl<Elem = $E> $trait for ($($name),+) } )*
31 };
32}
33
34impl_raw_tuple_store! {
35 impl<Elem = T> RawSpace for {
36 (T, T),
37 (T, T, T),
38 (T, T, T, T),
39 (T, T, T, T, T),
40 (T, T, T, T, T, T),
41 (T, T, T, T, T, T, T),
42 (T, T, T, T, T, T, T, T),
43 (T, T, T, T, T, T, T, T, T),
44 (T, T, T, T, T, T, T, T, T, T),
45 (T, T, T, T, T, T, T, T, T, T, T),
46 (T, T, T, T, T, T, T, T, T, T, T, T),
47 }
48}
49
50impl_raw_space! {
51 impl<Elem = T> RawSpace for {
52 core::option::Option<T>,
53 core::cell::Cell<T>,
54 core::cell::OnceCell<T>,
55 core::cell::RefCell<T>,
56 core::cell::UnsafeCell<T>,
57 core::ops::Range<T>,
58 core::result::Result<T, E>,
59 }
60}
61
62#[cfg(all(feature = "alloc", not(feature = "nightly")))]
63impl_raw_space! {
64 impl<Elem = T> RawSpace for {
65 alloc::boxed::Box<T>,
66 alloc::rc::Rc<T>,
67 alloc::sync::Arc<T>,
68 alloc::collections::BTreeSet<T>,
69 alloc::collections::LinkedList<T>,
70 alloc::collections::VecDeque<T>,
71 alloc::collections::BinaryHeap<T>,
72 alloc::collections::BTreeMap<K, T>,
73 alloc::collections::btree_map::Entry<'a, K, T>,
74 alloc::vec::Vec<T>,
75 }
76}
77
78#[cfg(all(feature = "alloc", feature = "nightly"))]
79impl_raw_space! {
80 impl<Elem = T> RawSpace for {
81 alloc::collections::BTreeSet<T, A> { where A: alloc::allocator::Allocator },
82 alloc::collections::LinkedList<T, A> { where A: alloc::allocator::Allocator },
83 alloc::collections::VecDeque<T, A> { where A: alloc::allocator::Allocator },
84 alloc::collections::BinaryHeap<T, A> { where A: alloc::allocator::Allocator },
85 alloc::collections::BTreeMap<K, T, A> { where A: alloc::allocator::Allocator },
86 alloc::collections::btree_map::Entry<'a, K, T, a> { where A: alloc::allocator::Allocator },
87 alloc::vec::Vec<T, A> { where A: alloc::allocator::Allocator },
88 }
89}
90
91#[cfg(feature = "std")]
92impl_raw_space! {
93 impl<Elem = T> RawSpace for {
94 std::sync::Mutex<T>,
95 std::sync::RwLock<T>,
96 std::sync::LazyLock<T>,
97 std::collections::HashMap<K, T>,
98 std::collections::HashSet<T>,
99
100 }
101}
102
103#[cfg(feature = "hashbrown")]
104impl_raw_space! {
105 impl<Elem = T> RawSpace for {
106 hashbrown::HashMap<K, T, S>,
107 hashbrown::HashSet<T, S>,
108 }
109}
110
111#[cfg(feature = "complex")]
112impl<T> RawSpace for num_complex::Complex<T> {
113 type Elem = T;
114}
115
116impl<T> RawSpace for [T] {
117 type Elem = T;
118}
119
120impl<T> RawSpace for &[T] {
121 type Elem = T;
122}
123
124impl<T> RawSpace for &mut [T] {
125 type Elem = T;
126}
127
128impl<const N: usize, T> RawSpace for [T; N] {
129 type Elem = T;
130}