use crate::{ Capacity, Clear, Collection, CollectionMut, CollectionRef, Get, GetMut, Insert, Len, Remove, Reserve, SimpleCollectionMut, SimpleCollectionRef, WithCapacity, }; use slab::Slab; impl Collection for Slab { type Item = T; } impl CollectionRef for Slab { type ItemRef<'a> = &'a T where Self: 'a; crate::covariant_item_ref!(); } impl CollectionMut for Slab { type ItemMut<'a> = &'a mut T where Self: 'a; crate::covariant_item_mut!(); } impl SimpleCollectionRef for Slab { crate::simple_collection_ref!(); } impl SimpleCollectionMut for Slab { crate::simple_collection_mut!(); } impl WithCapacity for Slab { fn with_capacity(capacity: usize) -> Self { Slab::with_capacity(capacity) } } impl Len for Slab { fn len(&self) -> usize { self.len() } } impl Capacity for Slab { fn capacity(&self) -> usize { self.capacity() } } impl Reserve for Slab { fn reserve(&mut self, additional: usize) { self.reserve(additional) } } impl Get for Slab { fn get(&self, key: usize) -> Option<&Self::Item> { self.get(key) } } impl GetMut for Slab { fn get_mut(&mut self, key: usize) -> Option<&mut Self::Item> { self.get_mut(key) } } impl Insert for Slab { type Output = usize; fn insert(&mut self, element: T) -> usize { self.insert(element) } } impl Remove for Slab { fn remove(&mut self, key: usize) -> Option { if self.contains(key) { Some(self.remove(key)) } else { None } } } impl Clear for Slab { fn clear(&mut self) { self.clear() } }