Hacker News new | ask | show | jobs
by gameswithgo 1479 days 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.

1 comments

There'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)