aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_arena
diff options
context:
space:
mode:
authorkjeremy <[email protected]>2020-03-31 14:02:12 +0100
committerkjeremy <[email protected]>2020-03-31 14:02:12 +0100
commit7ca5ef67e89241065d328445ed7d361270f4b9de (patch)
tree446416b55a026ab02b5921f91e67ff6bc4766d04 /crates/ra_arena
parentf633f69e36f0aee2cb77a3436b54aeca9aa0d10e (diff)
Use resize_with
Diffstat (limited to 'crates/ra_arena')
-rw-r--r--crates/ra_arena/src/map.rs3
1 files changed, 1 insertions, 2 deletions
diff --git a/crates/ra_arena/src/map.rs b/crates/ra_arena/src/map.rs
index e4ddbad42..0f33907c0 100644
--- a/crates/ra_arena/src/map.rs
+++ b/crates/ra_arena/src/map.rs
@@ -15,8 +15,7 @@ impl<T, V> ArenaMap<Idx<T>, V> {
15 pub fn insert(&mut self, id: Idx<T>, t: V) { 15 pub fn insert(&mut self, id: Idx<T>, t: V) {
16 let idx = Self::to_idx(id); 16 let idx = Self::to_idx(id);
17 17
18 let fill = (idx + 1).saturating_sub(self.v.len()); 18 self.v.resize_with((idx + 1).max(self.v.len()), || None);
19 self.v.extend(std::iter::repeat_with(|| None).take(fill));
20 self.v[idx] = Some(t); 19 self.v[idx] = Some(t);
21 } 20 }
22 21