Rollup merge of #126118 - jan-ferdinand:docs_for_vec_set_len, r=the8472

docs: Mention `spare_capacity_mut()` in `Vec::set_len`

I recently went down a small rabbit hole when trying to identify safe use of `Vec::set_len`. The solution was `Vec::spare_capacity_mut`. I think the docs on `Vec::set_len` benefit from mentioning this method.

A possible counter-argument could be that the [clippy lint `uninit_vec`](https://rust-lang.github.io/rust-clippy/master/index.html#/uninit_vec) already nudges people in the right direction. However, I think a working example on `Vec::set_len` is still beneficial.

Happy to hear your thoughts on the matter. 😊
This commit is contained in:
Jacob Pratt 2024-12-20 01:36:45 -05:00 committed by GitHub
commit 969a1f526c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

Diff content is not available