mirror of
https://github.com/rust-lang/rust-analyzer
synced 2024-12-27 13:33:31 +00:00
Simplify entry API usage
This commit is contained in:
parent
56fb8a401a
commit
a80e8fea85
1 changed files with 12 additions and 21 deletions
|
@ -158,31 +158,22 @@ impl ItemScope {
|
||||||
let mut changed = false;
|
let mut changed = false;
|
||||||
|
|
||||||
if let Some(types) = def.types {
|
if let Some(types) = def.types {
|
||||||
match self.types.entry(name.clone()) {
|
self.types.entry(name.clone()).or_insert_with(|| {
|
||||||
Entry::Occupied(_) => {}
|
|
||||||
Entry::Vacant(e) => {
|
|
||||||
e.insert(types);
|
|
||||||
changed = true;
|
changed = true;
|
||||||
}
|
types
|
||||||
}
|
});
|
||||||
}
|
}
|
||||||
if let Some(values) = def.values {
|
if let Some(values) = def.values {
|
||||||
match self.values.entry(name.clone()) {
|
self.values.entry(name.clone()).or_insert_with(|| {
|
||||||
Entry::Occupied(_) => {}
|
|
||||||
Entry::Vacant(e) => {
|
|
||||||
e.insert(values);
|
|
||||||
changed = true;
|
changed = true;
|
||||||
}
|
values
|
||||||
}
|
});
|
||||||
}
|
}
|
||||||
if let Some(macros) = def.macros {
|
if let Some(macros) = def.macros {
|
||||||
match self.macros.entry(name.clone()) {
|
self.macros.entry(name.clone()).or_insert_with(|| {
|
||||||
Entry::Occupied(_) => {}
|
|
||||||
Entry::Vacant(e) => {
|
|
||||||
e.insert(macros);
|
|
||||||
changed = true;
|
changed = true;
|
||||||
}
|
macros
|
||||||
}
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
if def.is_none() {
|
if def.is_none() {
|
||||||
|
|
Loading…
Reference in a new issue