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