diff options
Diffstat (limited to 'src/docs/slow_vector_initialization.txt')
| -rw-r--r-- | src/docs/slow_vector_initialization.txt | 24 |
1 files changed, 0 insertions, 24 deletions
diff --git a/src/docs/slow_vector_initialization.txt b/src/docs/slow_vector_initialization.txt deleted file mode 100644 index 53442e17965..00000000000 --- a/src/docs/slow_vector_initialization.txt +++ /dev/null @@ -1,24 +0,0 @@ -### What it does -Checks slow zero-filled vector initialization - -### Why is this bad? -These structures are non-idiomatic and less efficient than simply using -`vec![0; len]`. - -### Example -``` -let mut vec1 = Vec::with_capacity(len); -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)); -``` - -Use instead: -``` -let mut vec1 = vec![0; len]; -let mut vec2 = vec![0; len]; -``` \ No newline at end of file |
