Skip to content

Commit

Permalink
Rollup merge of rust-lang#80972 - KodrAus:deprecate/remove_item, r=na…
Browse files Browse the repository at this point in the history
…gisa

Remove unstable deprecated Vec::remove_item

Closes rust-lang#40062

The `Vec::remove_item` method was deprecated in `1.46.0` (in August of 2020). This PR now removes that unstable method entirely.
  • Loading branch information
JohnTitor authored Jan 14, 2021
2 parents b4747e8 + 7e83fec commit f83fead
Showing 1 changed file with 0 additions and 21 deletions.
21 changes: 0 additions & 21 deletions library/alloc/src/vec/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1953,27 +1953,6 @@ impl<T: PartialEq, A: Allocator> Vec<T, A> {
}
}

impl<T, A: Allocator> Vec<T, A> {
/// Removes the first instance of `item` from the vector if the item exists.
///
/// This method will be removed soon.
#[unstable(feature = "vec_remove_item", reason = "recently added", issue = "40062")]
#[rustc_deprecated(
reason = "Removing the first item equal to a needle is already easily possible \
with iterators and the current Vec methods. Furthermore, having a method for \
one particular case of removal (linear search, only the first item, no swap remove) \
but not for others is inconsistent. This method will be removed soon.",
since = "1.46.0"
)]
pub fn remove_item<V>(&mut self, item: &V) -> Option<T>
where
T: PartialEq<V>,
{
let pos = self.iter().position(|x| *x == *item)?;
Some(self.remove(pos))
}
}

////////////////////////////////////////////////////////////////////////////////
// Internal methods and functions
////////////////////////////////////////////////////////////////////////////////
Expand Down

0 comments on commit f83fead

Please sign in to comment.