Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

This should be in the docs or a blog post somewhere. Very clear explanation.


That's a nice idea, thank you. I have personal blog, I'll try to clean it up a bit and provide performance measurements so it's worth posting.

Regarding the official documentation, I've returned to read them. I agree that the docs would benefit from more discussion about when to use each method. In particular, the code examples are currently exactly the same which is not great. Still, the most critical piece of information is there [0]

> Prefer `reserve` if future insertions are expected.

If anyone wants to reuse my explanation above, feel free to do it; no need to credit.

[0]: https://doc.rust-lang.org/std/vec/struct.Vec.html#method.res...


It is, though not worded as nicely as the GP comment.

docs: https://doc.rust-lang.org/std/vec/struct.Vec.html#method.res...




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: