Skip to content

Commit ef10694

Browse files
Deprecate Vec::remove_item
1 parent 033013c commit ef10694

File tree

1 file changed

+8
-10
lines changed

1 file changed

+8
-10
lines changed

src/liballoc/vec.rs

+8-10
Original file line numberDiff line numberDiff line change
@@ -1760,17 +1760,15 @@ impl<T: PartialEq> Vec<T> {
17601760
impl<T> Vec<T> {
17611761
/// Removes the first instance of `item` from the vector if the item exists.
17621762
///
1763-
/// # Examples
1764-
///
1765-
/// ```
1766-
/// # #![feature(vec_remove_item)]
1767-
/// let mut vec = vec![1, 2, 3, 1];
1768-
///
1769-
/// vec.remove_item(&1);
1770-
///
1771-
/// assert_eq!(vec, vec![2, 3, 1]);
1772-
/// ```
1763+
/// This method will be removed soon.
17731764
#[unstable(feature = "vec_remove_item", reason = "recently added", issue = "40062")]
1765+
#[rustc_deprecated(
1766+
reason = "Removing the first item equal to a needle is already easily possible \
1767+
with iterators and the current Vec methods. Furthermore, having a method for \
1768+
one particular case of removal (linear search, only the first item, no swap remove) \
1769+
but not for others is inconsistent. This method will be removed soon.",
1770+
since = "1.46.0"
1771+
)]
17741772
pub fn remove_item<V>(&mut self, item: &V) -> Option<T>
17751773
where
17761774
T: PartialEq<V>,

0 commit comments

Comments
 (0)