Using `Vec::extend(std::iter::repeat_n(item, N))` allows to use the more natural number of elements to add `N`, as is probably done in the original loop, instead of computing the difference between the existing number of elements and the wanted one. Before MSRV 1.82, the older suggestion to use `Vec::resize()` is still issued. Inspired by #6156 (which predates `repeat_n()`). changelog: [`same_item_push`]: recommend using `Vec::extend()` to extend a vector |
||
|---|---|---|
| .. | ||
| src | ||
| book.toml | ||
| README.md | ||