Skip to content

Commit 39dc87b

Browse files
committed
refactor: use entry API directly
1 parent b41dbf6 commit 39dc87b

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

src/cargo/util/context/mod.rs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,6 @@
6363
6464
use crate::util::cache_lock::{CacheLock, CacheLockMode, CacheLocker};
6565
use std::borrow::Cow;
66-
use std::collections::hash_map::Entry::Vacant;
6766
use std::collections::{HashMap, HashSet};
6867
use std::env;
6968
use std::ffi::{OsStr, OsString};
@@ -1714,11 +1713,10 @@ impl GlobalContext {
17141713
let (value_map, def) = value.table_mut("<root>")?;
17151714

17161715
if let Some(token) = value_map.remove("token") {
1717-
if let Vacant(entry) = value_map.entry("registry".into()) {
1716+
value_map.entry("registry".into()).or_insert_with(|| {
17181717
let map = HashMap::from([("token".into(), token)]);
1719-
let table = CV::Table(map, def.clone());
1720-
entry.insert(table);
1721-
}
1718+
CV::Table(map, def.clone())
1719+
});
17221720
}
17231721
}
17241722

0 commit comments

Comments
 (0)