#[cfg(all(feature = "alloc", not(feature = "std")))]
use alloc::vec::Vec;
pub trait Insert {
type Input;
type Output;
fn insert(&mut self, input: Self::Input) -> Self::Output;
}
impl<T> Insert for Option<T> {
type Input = T;
type Output = ();
#[inline]
fn insert(&mut self, input: Self::Input) {
*self = Some(input);
}
}
#[cfg(feature = "alloc")]
impl<T> Insert for Vec<T> {
type Input = (usize, T);
type Output = ();
#[inline]
fn insert(&mut self, input: Self::Input) {
self.insert(input.0, input.1)
}
}
#[cfg(feature = "with-arrayvec")]
impl<A> Insert for arrayvec::ArrayVec<A>
where
A: arrayvec::Array,
{
type Input = (usize, A::Item);
type Output = ();
#[inline]
fn insert(&mut self, input: Self::Input) {
self.insert(input.0, input.1)
}
}
#[cfg(feature = "with-smallvec")]
impl<A> Insert for smallvec::SmallVec<A>
where
A: smallvec::Array,
{
type Input = (usize, A::Item);
type Output = ();
#[inline]
fn insert(&mut self, input: Self::Input) {
self.insert(input.0, input.1)
}
}
#[cfg(feature = "with-staticvec")]
impl<T, const N: usize> Insert for staticvec::StaticVec<T, N> {
type Input = (usize, T);
type Output = ();
#[inline]
fn insert(&mut self, input: Self::Input) {
self.insert(input.0, input.1)
}
}
#[cfg(feature = "with-tinyvec")]
impl<A> Insert for tinyvec::ArrayVec<A>
where
A: tinyvec::Array,
A::Item: Default,
{
type Input = (usize, A::Item);
type Output = ();
#[inline]
fn insert(&mut self, input: Self::Input) {
self.insert(input.0, input.1)
}
}
#[cfg(all(feature = "alloc", feature = "with-tinyvec"))]
impl<A> Insert for tinyvec::TinyVec<A>
where
A: tinyvec::Array,
A::Item: Default,
{
type Input = (usize, A::Item);
type Output = ();
#[inline]
fn insert(&mut self, input: Self::Input) {
self.insert(input.0, input.1)
}
}