Add UnordMap::try_insert
This commit is contained in:
parent
fe9c5e6510
commit
3c815a644c
@ -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 @@ pub fn insert(&mut self, k: K, v: V) -> Option<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…
Reference in New Issue
Block a user