Skip to content

Commit

Permalink
Remove dropped remove_item
Browse files Browse the repository at this point in the history
  • Loading branch information
kornelski committed May 7, 2020
1 parent 63d0377 commit c5b7947
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 38 deletions.
15 changes: 0 additions & 15 deletions src/liballoc/tests/vec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -131,21 +131,6 @@ fn test_extend_ref() {
assert_eq!(v, [1, 2, 3, 4, 5, 6, 7]);
}

#[test]
fn test_remove_item() {
let mut v = vec![1, 2, 3];
v.remove_item(&1);

assert_eq!(v.len(), 2);
assert_eq!(v, [2, 3]);

let mut w = vec![1, 2, 3];
w.remove_item(&4);

assert_eq!(w.len(), 3);
w.remove_item(&4);
}

#[test]
fn test_slice_from_mut() {
let mut values = vec![1, 2, 3, 4, 5];
Expand Down
23 changes: 0 additions & 23 deletions src/liballoc/vec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1752,29 +1752,6 @@ impl<T: PartialEq> Vec<T> {
}
}

impl<T> Vec<T> {
/// Removes the first instance of `item` from the vector if the item exists.
///
/// # Examples
///
/// ```
/// # #![feature(vec_remove_item)]
/// let mut vec = vec![1, 2, 3, 1];
///
/// vec.remove_item(&1);
///
/// assert_eq!(vec, vec![2, 3, 1]);
/// ```
#[unstable(feature = "vec_remove_item", reason = "recently added", issue = "40062")]
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 c5b7947

Please sign in to comment.