Skip to content

Commit 82444aa

Browse files
committed
Add doc comments about safest way to initialize a vector of zeros
1 parent 2155f27 commit 82444aa

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

Diff for: src/liballoc/vec.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,9 @@ use raw_vec::RawVec;
120120
/// assert_eq!(vec, [1, 2, 3, 4]);
121121
/// ```
122122
///
123-
/// It can also initialize each element of a `Vec<T>` with a given value:
123+
/// It can also initialize each element of a `Vec<T>` with a given value.
124+
/// Initializing a `Vec<T>` in this manner is the most efficient and safest way to allocate a
125+
/// vector of zeros as previously zeroed memory is requested from the operating system:
124126
///
125127
/// ```
126128
/// let vec = vec![0; 5];

0 commit comments

Comments
 (0)