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