Skip to content

Commit

Permalink
explain safety for vec.set_len(0)
Browse files Browse the repository at this point in the history
  • Loading branch information
Centril committed Jan 9, 2019
1 parent 61fb909 commit 5052197
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 5052197

Please sign in to comment.