Add UnordMap::try_insert
This commit is contained in:
parent
fe9c5e6510
commit
3c815a644c
2 changed files with 7 additions and 0 deletions
|
@ -25,6 +25,7 @@
|
|||
#![feature(lazy_cell)]
|
||||
#![feature(lint_reasons)]
|
||||
#![feature(macro_metavar_expr)]
|
||||
#![feature(map_try_insert)]
|
||||
#![feature(maybe_uninit_uninit_array)]
|
||||
#![feature(min_specialization)]
|
||||
#![feature(negative_impls)]
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
|
||||
use rustc_hash::{FxHashMap, FxHashSet};
|
||||
use rustc_macros::{Decodable_Generic, Encodable_Generic};
|
||||
use std::collections::hash_map::OccupiedError;
|
||||
use std::{
|
||||
borrow::{Borrow, BorrowMut},
|
||||
collections::hash_map::Entry,
|
||||
|
@ -469,6 +470,11 @@ impl<K: Eq + Hash, V> UnordMap<K, V> {
|
|||
self.inner.insert(k, v)
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn try_insert(&mut self, k: K, v: V) -> Result<&mut V, OccupiedError<'_, K, V>> {
|
||||
self.inner.try_insert(k, v)
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn contains_key<Q: ?Sized>(&self, k: &Q) -> bool
|
||||
where
|
||||
|
|
Loading…
Add table
Reference in a new issue