From 10384ab18a386e6f7b58c714def62e405182d968 Mon Sep 17 00:00:00 2001 From: Jacob Kiesel Date: Mon, 18 Sep 2017 10:15:17 -0600 Subject: [PATCH] Add requested comment --- src/liballoc/vec.rs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/liballoc/vec.rs b/src/liballoc/vec.rs index cc0a60e747e6b..c5aaaac8f76be 100644 --- a/src/liballoc/vec.rs +++ b/src/liballoc/vec.rs @@ -2694,6 +2694,9 @@ impl<'a, T, F> Iterator for DrainFilter<'a, T, F> let del = self.del; let src: *const T = &v[i]; let dst: *mut T = &mut v[i - del]; + // This is safe because self.vec has length 0 + // thus its elements will not have Drop::drop + // called on them in the event of a panic. ptr::copy_nonoverlapping(src, dst, 1); } }