Skip to content

Commit 181d811

Browse files
committed
avoid no-op when truncating vec to same size
1 parent b1277d0 commit 181d811

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

library/alloc/src/vec.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -716,7 +716,7 @@ impl<T> Vec<T> {
716716
/// assert_eq!(vec, [1, 2]);
717717
/// ```
718718
///
719-
/// No truncation occurs when `len` is greater than the vector's current
719+
/// No truncation occurs when `len` is greater than or equal to the vector's current
720720
/// length:
721721
///
722722
/// ```
@@ -746,7 +746,7 @@ impl<T> Vec<T> {
746746
// such that no value will be dropped twice in case `drop_in_place`
747747
// were to panic once (if it panics twice, the program aborts).
748748
unsafe {
749-
if len > self.len {
749+
if len >= self.len {
750750
return;
751751
}
752752
let remaining_len = self.len - len;

0 commit comments

Comments
 (0)