I've got a vector:
let v = Vec<T>::with_capacity(10);
I want to populate it with data, in reverse order:
let i = 10;
while i > 0 {
i -= 1;
v[i] = non_pure_function(i);
}
Unfortunately, this panics; when allocating with Vec::with_capacity
, the actual initial length of the vector is still 0
.
How can I best accomplish this? What if I have no constructor for T
?