#![doc(test(attr(deny(warnings))))]
#![warn(missing_docs)]
use std::iter;
pub trait VecLike: IntoIterator<Item=Self::T>+iter::Extend<Self::T> {
type T;
#[inline(always)]
fn new() -> Self
where Self: Sized {
Self::with_capacity(0)
}
fn with_capacity(n: usize) -> Self
where Self: Sized;
#[inline]
fn map_elements<T2, E2>(self, f: impl FnMut(Self::T) -> T2) -> E2
where
E2: VecLike<T=T2>,
Self: Sized,
{
let mut new_elements = E2::with_capacity(self.len());
new_elements.extend(self.into_iter().map(f));
new_elements
}
fn push(&mut self, x: Self::T);
fn pop(&mut self) -> Option<Self::T>;
fn len(&self) -> usize;
#[inline(always)]
fn is_empty(&self) -> bool { self.len() == 0 }
fn as_slice(&self) -> &[Self::T];
}
impl<T> VecLike for Vec<T> {
type T = T;
#[inline(always)]
fn new() -> Self { Vec::new() }
#[inline(always)]
fn with_capacity(n: usize) -> Self { Vec::with_capacity(n) }
#[inline(always)]
fn push(&mut self, x: T) { Vec::push(self, x); }
#[inline(always)]
fn pop(&mut self) -> Option<T> { Vec::pop(self) }
#[inline(always)]
fn len(&self) -> usize { Vec::len(self) }
#[inline(always)]
fn is_empty(&self) -> bool { Vec::is_empty(self) }
#[inline(always)]
fn as_slice(&self) -> &[Self::T] { &self[..] }
}
#[cfg(feature = "smallvec")]
impl<T, const N: usize> VecLike for SmallVec<T, N> {
type T = T;
#[inline(always)]
fn new() -> Self { SmallVec::new() }
#[inline(always)]
fn with_capacity(n: usize) -> Self { SmallVec::with_capacity(n) }
#[inline(always)]
fn push(&mut self, x: T) { SmallVec::push(self, x); }
#[inline(always)]
fn pop(&mut self) -> Option<T> { SmallVec::pop(self) }
#[inline(always)]
fn len(&self) -> usize { SmallVec::len(self) }
#[inline(always)]
fn is_empty(&self) -> bool { SmallVec::is_empty(self) }
#[inline(always)]
fn as_slice(&self) -> &[Self::T] { &self[..] }
}
pub trait ConstDefault {
const DEFAULT: Self;
}
impl<T> ConstDefault for Vec<T> {
const DEFAULT: Self = Vec::new();
}
#[cfg(feature = "smallvec")]
impl<T, const N: usize> ConstDefault for SmallVec<T, N> {
const DEFAULT: Self = SmallVec::new();
}