mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-10-01 11:31:15 +00:00
Use more functional programming in ArenaMap::insert
I find this more readable and it flattens out the body a little.
This commit is contained in:
parent
6f0d8db529
commit
c39725212c
@ -17,11 +17,9 @@ impl<T, V> ArenaMap<Idx<T>, V> {
|
|||||||
if self.v.capacity() <= idx {
|
if self.v.capacity() <= idx {
|
||||||
self.v.reserve(idx + 1 - self.v.capacity());
|
self.v.reserve(idx + 1 - self.v.capacity());
|
||||||
}
|
}
|
||||||
if self.v.len() <= idx {
|
|
||||||
while self.v.len() <= idx {
|
let fill = (idx + 1).saturating_sub(self.v.len());
|
||||||
self.v.push(None);
|
self.v.extend(std::iter::repeat_with(|| None).take(fill));
|
||||||
}
|
|
||||||
}
|
|
||||||
self.v[idx] = Some(t);
|
self.v[idx] = Some(t);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user