diff --git a/library/alloc/src/collections/vec_deque/mod.rs b/library/alloc/src/collections/vec_deque/mod.rs index 1c33f8f60d82..8d50ad4fd96e 100644 --- a/library/alloc/src/collections/vec_deque/mod.rs +++ b/library/alloc/src/collections/vec_deque/mod.rs @@ -2782,10 +2782,14 @@ impl VecDeque { where P: FnMut(&T) -> bool, { - let (front, back) = self.as_slices(); + let (front, mut back) = self.as_slices(); if let Some(true) = back.first().map(|v| pred(v)) { - back.partition_point(pred) + front.len() + back = unsafe { + // SAFETY: if clause has proven a first element to skip exists + back.get_unchecked(1..) + }; + back.partition_point(pred) + front.len() + 1 } else { front.partition_point(pred) }