Skip to content

Commit

Permalink
Auto merge of rust-lang#11701 - Alexendoo:vec-init-then-push-docs, r=…
Browse files Browse the repository at this point in the history
…Jarcho

Use multiple pushes in `vec_init_then_push` example

Makes the perf argument clearer, since a single push doesn't have unnecessary allocations compared to `vec![x]`

changelog: none
  • Loading branch information
bors committed Oct 30, 2023
2 parents 325e9fd + e1b287c commit cdc4d56
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion clippy_lints/src/vec_init_then_push.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,12 @@ declare_clippy_lint! {
/// ```no_run
/// let mut v = Vec::new();
/// v.push(0);
/// v.push(1);
/// v.push(2);
/// ```
/// Use instead:
/// ```no_run
/// let v = vec![0];
/// let v = vec![0, 1, 2];
/// ```
#[clippy::version = "1.51.0"]
pub VEC_INIT_THEN_PUSH,
Expand Down

0 comments on commit cdc4d56

Please sign in to comment.