ef em ti ... :P

This commit is contained in:
dylan_DPC 2020-01-04 23:57:34 +05:30
parent eb36688a01
commit f744ea03b4
2 changed files with 6 additions and 7 deletions

View file

@ -133,13 +133,13 @@ fn test_extend_ref() {
#[test]
fn test_remove_item() {
let mut v = vec![1,2,3];
let mut v = vec![1, 2, 3];
v.remove_item(&1);
assert_eq!(v.len(), 2);
assert_eq!(v, [2,3]);
assert_eq!(v, [2, 3]);
let mut w = vec![1,2,3];
let mut w = vec![1, 2, 3];
w.remove_item(&4);
assert_eq!(w.len(), 3);

View file

@ -1690,8 +1690,7 @@ impl<T: PartialEq> Vec<T> {
}
}
impl <T> Vec<T> {
impl<T> Vec<T> {
/// Removes the first instance of `item` from the vector if the item exists.
///
/// # Examples
@ -1707,12 +1706,12 @@ impl <T> Vec<T> {
#[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>
where
T: PartialEq<V>,
{
let pos = self.iter().position(|x| *x == *item)?;
Some(self.remove(pos))
}
}
////////////////////////////////////////////////////////////////////////////////