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
m-ou-se authored Jan 14, 2021
2 parents 90cc815 + 7e83fec commit 9bfe6f1
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 9bfe6f1

Please sign in to comment.