Skip to content

Commit

Permalink
remove bounds from vec and linkedlist ExtractIf
Browse files Browse the repository at this point in the history
since drain-on-drop behavior was removed those bounds
no longer serve a purpose
  • Loading branch information
the8472 committed Nov 20, 2024
1 parent 19aae9f commit f1e2d70
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 19 deletions.
9 changes: 2 additions & 7 deletions library/alloc/src/collections/linked_list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1939,9 +1939,7 @@ pub struct ExtractIf<
T: 'a,
F: 'a,
#[unstable(feature = "allocator_api", issue = "32838")] A: Allocator = Global,
> where
F: FnMut(&mut T) -> bool,
{
> {
list: &'a mut LinkedList<T, A>,
it: Option<NonNull<Node<T>>>,
pred: F,
Expand Down Expand Up @@ -1979,10 +1977,7 @@ where
}

#[unstable(feature = "extract_if", reason = "recently added", issue = "43244")]
impl<T: fmt::Debug, F> fmt::Debug for ExtractIf<'_, T, F>
where
F: FnMut(&mut T) -> bool,
{
impl<T: fmt::Debug, F> fmt::Debug for ExtractIf<'_, T, F> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.debug_tuple("ExtractIf").field(&self.list).finish()
}
Expand Down
17 changes: 5 additions & 12 deletions library/alloc/src/vec/extract_if.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use core::{ops::{Range, RangeBounds}, ptr, slice};
use core::ops::{Range, RangeBounds};
use core::{ptr, slice};

use super::Vec;
use crate::alloc::{Allocator, Global};
Expand All @@ -24,9 +25,7 @@ pub struct ExtractIf<
T,
F,
#[unstable(feature = "allocator_api", issue = "32838")] A: Allocator = Global,
> where
F: FnMut(&mut T) -> bool,
{
> {
pub(super) vec: &'a mut Vec<T, A>,
/// The index of the item that will be inspected by the next call to `next`.
pub(super) idx: usize,
Expand All @@ -40,10 +39,7 @@ pub struct ExtractIf<
pub(super) pred: F,
}

impl<'a, T, F, A: Allocator> ExtractIf<'a, T, F, A>
where
F: FnMut(&mut T) -> bool,
{
impl<'a, T, F, A: Allocator> ExtractIf<'a, T, F, A> {
pub(super) fn new<R: RangeBounds<usize>>(vec: &'a mut Vec<T, A>, pred: F, range: R) -> Self {
let old_len = vec.len();
let Range { start, end } = slice::range(range, ..old_len);
Expand Down Expand Up @@ -100,10 +96,7 @@ where
}

#[unstable(feature = "extract_if", reason = "recently added", issue = "43244")]
impl<T, F, A: Allocator> Drop for ExtractIf<'_, T, F, A>
where
F: FnMut(&mut T) -> bool,
{
impl<T, F, A: Allocator> Drop for ExtractIf<'_, T, F, A> {
fn drop(&mut self) {
unsafe {
if self.idx < self.old_len && self.del > 0 {
Expand Down

0 comments on commit f1e2d70

Please sign in to comment.