use crate::{ Capacity, Clear, Collection, CollectionMut, CollectionRef, Get, GetMut, Iter, IterMut, Len, PopBack, PushBack, Remove, Reserve, SimpleCollectionMut, SimpleCollectionRef, WithCapacity, }; use smallvec::{Array, SmallVec}; impl Collection for SmallVec { type Item = A::Item; } impl CollectionRef for SmallVec { type ItemRef<'a> = &'a A::Item where Self: 'a; crate::covariant_item_ref!(); } impl CollectionMut for SmallVec { type ItemMut<'a> = &'a mut A::Item where Self: 'a; crate::covariant_item_mut!(); } impl SimpleCollectionRef for SmallVec { crate::simple_collection_ref!(); } impl SimpleCollectionMut for SmallVec { crate::simple_collection_mut!(); } impl WithCapacity for SmallVec { #[inline(always)] fn with_capacity(capacity: usize) -> Self { SmallVec::with_capacity(capacity) } } impl Len for SmallVec { #[inline(always)] fn len(&self) -> usize { self.len() } #[inline(always)] fn is_empty(&self) -> bool { self.is_empty() } } impl Capacity for SmallVec { #[inline(always)] fn capacity(&self) -> usize { self.capacity() } } impl Reserve for SmallVec { #[inline(always)] fn reserve(&mut self, additional: usize) { self.reserve(additional) } } impl Get for SmallVec { #[inline(always)] fn get(&self, index: usize) -> Option<&A::Item> { self.as_slice().get(index) } } impl GetMut for SmallVec { #[inline(always)] fn get_mut(&mut self, index: usize) -> Option<&mut A::Item> { self.as_mut_slice().get_mut(index) } } impl PushBack for SmallVec { type Output = (); #[inline(always)] fn push_back(&mut self, t: A::Item) { self.push(t) } } impl PopBack for SmallVec { #[inline(always)] fn pop_back(&mut self) -> Option { self.pop() } } impl Remove for SmallVec { #[inline(always)] fn remove(&mut self, index: usize) -> Option { if index < self.len() { Some(self.remove(index)) } else { None } } } impl Clear for SmallVec { #[inline(always)] fn clear(&mut self) { self.clear() } } impl Iter for SmallVec { type Iter<'a> = core::slice::Iter<'a, A::Item> where Self: 'a; #[inline(always)] fn iter(&self) -> Self::Iter<'_> { self.as_slice().iter() } } impl IterMut for SmallVec { type IterMut<'a> = core::slice::IterMut<'a, A::Item> where Self: 'a; #[inline(always)] fn iter_mut(&mut self) -> Self::IterMut<'_> { self.as_mut_slice().iter_mut() } }