diff options
Diffstat (limited to 'crates/ra_arena')
-rw-r--r-- | crates/ra_arena/src/map.rs | 3 |
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 | ||