about summary refs log tree commit diff
path: root/src/docs/same_item_push.txt
diff options
context:
space:
mode:
Diffstat (limited to 'src/docs/same_item_push.txt')
-rw-r--r--src/docs/same_item_push.txt29
1 files changed, 0 insertions, 29 deletions
diff --git a/src/docs/same_item_push.txt b/src/docs/same_item_push.txt
deleted file mode 100644
index 7e724073f8a..00000000000
--- a/src/docs/same_item_push.txt
+++ /dev/null
@@ -1,29 +0,0 @@
-### What it does
-Checks whether a for loop is being used to push a constant
-value into a Vec.
-
-### Why is this bad?
-This kind of operation can be expressed more succinctly with
-`vec![item; SIZE]` or `vec.resize(NEW_SIZE, item)` and using these alternatives may also
-have better performance.
-
-### Example
-```
-let item1 = 2;
-let item2 = 3;
-let mut vec: Vec<u8> = Vec::new();
-for _ in 0..20 {
-   vec.push(item1);
-}
-for _ in 0..30 {
-    vec.push(item2);
-}
-```
-
-Use instead:
-```
-let item1 = 2;
-let item2 = 3;
-let mut vec: Vec<u8> = vec![item1; 20];
-vec.resize(20 + 30, item2);
-```
\ No newline at end of file