3 ms·
You can specify the capacity on creation: Vec::with_capacity(foo) There are also alternative vector like types for different use cases, and you can roll your o
by gameswithgo 4y ago
You can specify the capacity on creation: Vec::with_capacity(foo)
There are also alternative vector like types for different use cases, and you can roll your own.
- __s 4y agoThere's also crates to avoid heap allocations for usually small vectors: tinyvec, smallvec, arrayvec Note: gameswithgo you seem to be shadow banned. Your comment history looks alright tho. You may want to email hn@ycombinator.com asking to have that fixed (edit: found the culprit https://news.ycombinator.com/item?id=30732886 https://news.ycombinator.com/item?id=30732886)