#[cfg(feature = "alloc")]
use alloc::vec::Vec;
pub trait Remove {
type Error;
type Input;
type Output;
fn remove(&mut self, idx: Self::Input) -> Result<Self::Output, Self::Error>;
}
#[cfg(feature = "alloc")]
impl<T> Remove for Vec<T> {
type Error = crate::Error;
type Input = usize;
type Output = T;
#[inline]
fn remove(&mut self, idx: Self::Input) -> Result<Self::Output, Self::Error> {
_check_indcs!(self, idx);
Ok(self.remove(idx))
}
}
#[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, idx: Self::Input) -> Result<Self::Output, Self::Error> {
_check_indcs!(self, idx);
Ok(self.remove(idx))
}
}
#[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, idx: Self::Input) -> Result<Self::Output, Self::Error> {
_check_indcs!(self, idx);
Ok(self.remove(idx))
}
}
#[cfg(feature = "staticvec")]
impl<T, const N: usize> Remove for staticvec::StaticVec<T, N> {
type Error = crate::Error;
type Input = usize;
type Output = T;
#[inline]
fn remove(&mut self, idx: Self::Input) -> Result<Self::Output, Self::Error> {
_check_indcs!(self, idx);
Ok(self.remove(idx))
}
}
#[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, idx: Self::Input) -> Result<Self::Output, Self::Error> {
_check_indcs!(self, idx);
Ok(self.remove(idx))
}
}
#[cfg(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, idx: Self::Input) -> Result<Self::Output, Self::Error> {
_check_indcs!(self, idx);
Ok(self.remove(idx))
}
}