From 181d811867952b60727f82f73b44c092df3c4c01 Mon Sep 17 00:00:00 2001 From: flotts Date: Sun, 8 Nov 2020 12:44:12 -0500 Subject: [PATCH] avoid no-op when truncating vec to same size --- library/alloc/src/vec.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/library/alloc/src/vec.rs b/library/alloc/src/vec.rs index 202e3a836384d..0916ea37d073e 100644 --- a/library/alloc/src/vec.rs +++ b/library/alloc/src/vec.rs @@ -716,7 +716,7 @@ impl Vec { /// 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: /// /// ``` @@ -746,7 +746,7 @@ impl Vec { // 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;