#[cfg(feature = "alloc")]
use alloc::vec::Vec;
pub trait Remove {
type Error;
type Input;
type Output;
fn remove(&mut self, input: Self::Input) -> Result<Self::Output, Self::Error>;
}
impl<T> Remove for &mut T
where
T: Remove,
{
type Error = T::Error;
type Input = T::Input;
type Output = T::Output;
#[inline]
fn remove(&mut self, input: Self::Input) -> Result<Self::Output, Self::Error> {
(*self).remove(input)
}
}
#[cfg(feature = "alloc")]
impl<T> Remove for Vec<T> {
type Error = crate::Error;
type Input = usize;
type Output = T;
#[inline]
fn remove(&mut self, input: Self::Input) -> Result<Self::Output, Self::Error> {
_check_indcs!(self, input);
Ok(self.remove(input))
}
}
#[cfg(feature = "arrayvec")]
impl<T, const N: usize> Remove for arrayvec::ArrayVec<T, N> {
type Error = crate::Error;
type Input = usize;
type Output = T;
#[inline]
fn remove(&mut self, input: Self::Input) -> Result<Self::Output, Self::Error> {
_check_indcs!(self, input);
Ok(self.remove(input))
}
}
#[cfg(feature = "smallvec")]
impl<A> Remove for smallvec::SmallVec<A>
where
A: smallvec::Array,
{
type Error = crate::Error;
type Input = usize;
type Output = A::Item;
#[inline]
fn remove(&mut self, input: Self::Input) -> Result<Self::Output, Self::Error> {
_check_indcs!(self, input);
Ok(self.remove(input))
}
}
#[cfg(feature = "tinyvec")]
impl<A> Remove for tinyvec::ArrayVec<A>
where
A: tinyvec::Array,
A::Item: Default,
{
type Error = crate::Error;
type Input = usize;
type Output = A::Item;
#[inline]
fn remove(&mut self, input: Self::Input) -> Result<Self::Output, Self::Error> {
_check_indcs!(self, input);
Ok(self.remove(input))
}
}
#[cfg(all(feature = "alloc", feature = "tinyvec"))]
impl<A> Remove for tinyvec::TinyVec<A>
where
A: tinyvec::Array,
A::Item: Default,
{
type Error = crate::Error;
type Input = usize;
type Output = A::Item;
#[inline]
fn remove(&mut self, input: Self::Input) -> Result<Self::Output, Self::Error> {
_check_indcs!(self, input);
Ok(self.remove(input))
}
}