use crate::{ Clear, Collection, CollectionMut, CollectionRef, Get, GetKeyValue, GetMut, Iter, Keyed, KeyedRef, Len, MapInsert, MapIter, MapIterMut, Remove, SimpleCollectionMut, SimpleCollectionRef, SimpleKeyedRef, }; use alloc::collections::BTreeMap; use core::borrow::Borrow; impl Collection for BTreeMap { type Item = V; } impl CollectionRef for BTreeMap { type ItemRef<'a> = &'a V where Self: 'a; crate::covariant_item_ref!(); } impl CollectionMut for BTreeMap { type ItemMut<'a> = &'a mut V where Self: 'a; crate::covariant_item_mut!(); } impl SimpleCollectionRef for BTreeMap { crate::simple_collection_ref!(); } impl SimpleCollectionMut for BTreeMap { crate::simple_collection_mut!(); } impl Keyed for BTreeMap { type Key = K; } impl KeyedRef for BTreeMap { type KeyRef<'a> = &'a K where Self: 'a; crate::covariant_key_ref!(); } impl SimpleKeyedRef for BTreeMap { crate::simple_keyed_ref!(); } impl Len for BTreeMap { #[inline(always)] fn len(&self) -> usize { self.len() } #[inline(always)] fn is_empty(&self) -> bool { self.is_empty() } } impl<'a, Q, K: Ord, V> Get<&'a Q> for BTreeMap where K: Borrow, Q: Ord + ?Sized, { #[inline(always)] fn get(&self, key: &'a Q) -> Option<&V> { self.get(key) } } impl<'a, Q, K: Ord, V> GetKeyValue<&'a Q> for BTreeMap where K: Borrow, Q: Ord + ?Sized, { #[inline(always)] fn get_key_value(&self, key: &'a Q) -> Option<(&K, &V)> { self.get_key_value(key) } } impl<'a, Q, K: Ord, V> GetMut<&'a Q> for BTreeMap where K: Borrow, Q: Ord + ?Sized, { #[inline(always)] fn get_mut(&mut self, key: &'a Q) -> Option<&mut V> { self.get_mut(key) } } impl MapInsert for BTreeMap { type Output = Option; #[inline(always)] fn insert(&mut self, key: K, value: V) -> Option { self.insert(key, value) } } impl<'a, Q, K: Ord, V> Remove<&'a Q> for BTreeMap where K: Borrow, Q: Ord + ?Sized, { #[inline(always)] fn remove(&mut self, key: &'a Q) -> Option { self.remove(key) } } impl Clear for BTreeMap { #[inline(always)] fn clear(&mut self) { self.clear() } } impl Iter for BTreeMap { type Iter<'a> = alloc::collections::btree_map::Values<'a, K, V> where Self: 'a; #[inline(always)] fn iter(&self) -> Self::Iter<'_> { self.values() } } impl MapIter for BTreeMap { type Iter<'a> = alloc::collections::btree_map::Iter<'a, K, V> where Self: 'a; #[inline(always)] fn iter(&self) -> Self::Iter<'_> { self.iter() } } impl MapIterMut for BTreeMap { type IterMut<'a> = alloc::collections::btree_map::IterMut<'a, K, V> where Self: 'a; #[inline(always)] fn iter_mut(&mut self) -> Self::IterMut<'_> { self.iter_mut() } }