Skip to content

Commit

Permalink
Merge pull request #1 from Centril/redo-vec-set_len-docs-adjust
Browse files Browse the repository at this point in the history
Explain safety for `vec.set_len(0)`
  • Loading branch information
scottmcm committed Jan 9, 2019
2 parents 61fb909 + 5052197 commit 986e49d
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/liballoc/vec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -816,6 +816,9 @@ impl<T> Vec<T> {
/// let mut vec = vec![vec![1, 0, 0],
/// vec![0, 1, 0],
/// vec![0, 0, 1]];
/// // SAFETY:
/// // 1. `old_len..0` is empty so no elements need to be initialized.
/// // 2. `0 <= capacity` always holds whatever `capacity` is.
/// unsafe {
/// vec.set_len(0);
/// }
Expand Down

0 comments on commit 986e49d

Please sign in to comment.