mirror of
https://github.com/rust-lang/rust.git
synced 2025-04-16 22:16:53 +00:00
Rollup merge of #80857 - camelid:vec-truncate-comment, r=scottmcm
Add comment to `Vec::truncate` explaining `>` vs `>=` Hopefully this will prevent people from continuing to ask about this over and over again :) See [this Zulip discussion][1] for more. [1]: https://rust-lang.zulipchat.com/#narrow/stream/219381-t-libs/topic/Vec.3A.3Atruncate.20implementation r? ``@scottmcm``
This commit is contained in:
commit
19b8c65e4e
@ -990,6 +990,9 @@ impl<T, A: Allocator> Vec<T, A> {
|
||||
// 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 {
|
||||
// Note: It's intentional that this is `>` and not `>=`.
|
||||
// Changing it to `>=` has negative performance
|
||||
// implications in some cases. See #78884 for more.
|
||||
if len > self.len {
|
||||
return;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user