[Solved] How to fill a Vec with a value

See also

for the unfortunate lack of the obvious fill helper that you are probably looking for.

In the meantime, for a solution that iterates only once if your values have destructors, there's:

v.iter_mut().map(|x| *x = value).count();
4 Likes