1#[cfg(feature = "alloc")]
2use alloc::vec::Vec;
3
4pub trait Remove {
6 type Error;
8 type Input;
10 type Output;
12
13 fn remove(&mut self, input: Self::Input) -> Result<Self::Output, Self::Error>;
15}
16
17impl<T> Remove for &mut T
18where
19 T: Remove,
20{
21 type Error = T::Error;
22 type Input = T::Input;
23 type Output = T::Output;
24
25 #[inline]
26 fn remove(&mut self, input: Self::Input) -> Result<Self::Output, Self::Error> {
27 (*self).remove(input)
28 }
29}
30
31#[cfg(feature = "alloc")]
37impl<T> Remove for Vec<T> {
38 type Error = crate::Error;
39 type Input = usize;
40 type Output = T;
41
42 #[inline]
43 fn remove(&mut self, input: Self::Input) -> Result<Self::Output, Self::Error> {
44 _check_indcs!(self, input);
45 Ok(self.remove(input))
46 }
47}
48
49#[cfg(feature = "arrayvec")]
55impl<T, const N: usize> Remove for arrayvec::ArrayVec<T, N> {
56 type Error = crate::Error;
57 type Input = usize;
58 type Output = T;
59
60 #[inline]
61 fn remove(&mut self, input: Self::Input) -> Result<Self::Output, Self::Error> {
62 _check_indcs!(self, input);
63 Ok(self.remove(input))
64 }
65}
66
67#[cfg(feature = "smallvec")]
73impl<A> Remove for smallvec::SmallVec<A>
74where
75 A: smallvec::Array,
76{
77 type Error = crate::Error;
78 type Input = usize;
79 type Output = A::Item;
80
81 #[inline]
82 fn remove(&mut self, input: Self::Input) -> Result<Self::Output, Self::Error> {
83 _check_indcs!(self, input);
84 Ok(self.remove(input))
85 }
86}
87
88#[cfg(feature = "tinyvec")]
94impl<A> Remove for tinyvec::ArrayVec<A>
95where
96 A: tinyvec::Array,
97 A::Item: Default,
98{
99 type Error = crate::Error;
100 type Input = usize;
101 type Output = A::Item;
102
103 #[inline]
104 fn remove(&mut self, input: Self::Input) -> Result<Self::Output, Self::Error> {
105 _check_indcs!(self, input);
106 Ok(self.remove(input))
107 }
108}
109
110#[cfg(all(feature = "alloc", feature = "tinyvec"))]
116impl<A> Remove for tinyvec::TinyVec<A>
117where
118 A: tinyvec::Array,
119 A::Item: Default,
120{
121 type Error = crate::Error;
122 type Input = usize;
123 type Output = A::Item;
124
125 #[inline]
126 fn remove(&mut self, input: Self::Input) -> Result<Self::Output, Self::Error> {
127 _check_indcs!(self, input);
128 Ok(self.remove(input))
129 }
130}