Skip to content

Commit

Permalink
avoid no-op when truncating vec to same size
Browse files Browse the repository at this point in the history
  • Loading branch information
feralfluid committed Nov 8, 2020
1 parent b1277d0 commit 181d811
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions library/alloc/src/vec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -716,7 +716,7 @@ impl<T> Vec<T> {
/// assert_eq!(vec, [1, 2]);
/// ```
///
/// No truncation occurs when `len` is greater than the vector's current
/// No truncation occurs when `len` is greater than or equal to the vector's current
/// length:
///
/// ```
Expand Down Expand Up @@ -746,7 +746,7 @@ impl<T> Vec<T> {
// such that no value will be dropped twice in case `drop_in_place`
// were to panic once (if it panics twice, the program aborts).
unsafe {
if len > self.len {
if len >= self.len {
return;
}
let remaining_len = self.len - len;
Expand Down

0 comments on commit 181d811

Please sign in to comment.