mirror of
https://github.com/rust-lang/rust-analyzer
synced 2024-11-10 15:14:32 +00:00
Use resize_with
This commit is contained in:
parent
f633f69e36
commit
7ca5ef67e8
1 changed files with 1 additions and 2 deletions
|
@ -15,8 +15,7 @@ impl<T, V> ArenaMap<Idx<T>, V> {
|
|||
pub fn insert(&mut self, id: Idx<T>, t: V) {
|
||||
let idx = Self::to_idx(id);
|
||||
|
||||
let fill = (idx + 1).saturating_sub(self.v.len());
|
||||
self.v.extend(std::iter::repeat_with(|| None).take(fill));
|
||||
self.v.resize_with((idx + 1).max(self.v.len()), || None);
|
||||
self.v[idx] = Some(t);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue