about summary refs log tree commit diff
diff options
context:
space:
mode:
authory21 <30553356+y21@users.noreply.github.com>2023-08-09 14:48:31 +0200
committery21 <30553356+y21@users.noreply.github.com>2023-08-09 14:48:31 +0200
commitdd25cc349be3dae9b7c7f1ad0465ab14fab773e3 (patch)
tree2bd4f63ef0b4969d53feee107c0428c33fc481d9
parentd2acfb37b3344de3405457e02c4703cfc74bcb95 (diff)
downloadrust-dd25cc349be3dae9b7c7f1ad0465ab14fab773e3.tar.gz
rust-dd25cc349be3dae9b7c7f1ad0465ab14fab773e3.zip
Remove unnecessary paragraph, move examples
-rw-r--r--clippy_lints/src/slow_vector_initialization.rs16
1 files changed, 4 insertions, 12 deletions
diff --git a/clippy_lints/src/slow_vector_initialization.rs b/clippy_lints/src/slow_vector_initialization.rs
index 1001441b03d..c9ab622ad25 100644
--- a/clippy_lints/src/slow_vector_initialization.rs
+++ b/clippy_lints/src/slow_vector_initialization.rs
@@ -29,26 +29,18 @@ declare_clippy_lint! {
     /// it involves two operations for allocating and initializing.
     /// The `resize` call first allocates memory (since `Vec::new()` did not), and only *then* zero-initializes it.
     ///
-    /// Writing `Vec::with_capacity(size)` followed by `vec.resize(len, 0)` is similar.
-    /// The allocation shifts from `resize` to `with_capacity`,
-    /// but the zero-initialization still happens separately,
-    /// when it could be done in one call with `vec![0; len]` (`alloc_zeroed`).
-    ///
     /// ### Example
     /// ```rust
     /// # use core::iter::repeat;
     /// # let len = 4;
-    /// let mut vec1 = Vec::with_capacity(len);
+    /// let mut vec1 = Vec::new();
     /// vec1.resize(len, 0);
     ///
-    /// let mut vec1 = Vec::with_capacity(len);
-    /// vec1.resize(vec1.capacity(), 0);
-    ///
     /// let mut vec2 = Vec::with_capacity(len);
-    /// vec2.extend(repeat(0).take(len));
+    /// vec2.resize(len, 0);
     ///
-    /// let mut vec3 = Vec::new();
-    /// vec3.resize(len, 0);
+    /// let mut vec3 = Vec::with_capacity(len);
+    /// vec3.extend(repeat(0).take(len));
     /// ```
     ///
     /// Use instead: