File tree Expand file tree Collapse file tree 1 file changed +8
-1
lines changed Expand file tree Collapse file tree 1 file changed +8
-1
lines changed Original file line number Diff line number Diff line change @@ -1688,6 +1688,9 @@ impl<T: PartialEq> Vec<T> {
1688
1688
pub fn dedup ( & mut self ) {
1689
1689
self . dedup_by ( |a, b| a == b)
1690
1690
}
1691
+ }
1692
+
1693
+ impl < T > Vec < T > {
1691
1694
1692
1695
/// Removes the first instance of `item` from the vector if the item exists.
1693
1696
///
@@ -1701,11 +1704,15 @@ impl<T: PartialEq> Vec<T> {
1701
1704
///
1702
1705
/// assert_eq!(vec, vec![2, 3, 1]);
1703
1706
/// ```
1707
+
1704
1708
#[ unstable( feature = "vec_remove_item" , reason = "recently added" , issue = "40062" ) ]
1705
- pub fn remove_item ( & mut self , item : & T ) -> Option < T > {
1709
+ pub fn remove_item < V > ( & mut self , item : & V ) -> Option < T >
1710
+ where T : PartialEq < V >
1711
+ {
1706
1712
let pos = self . iter ( ) . position ( |x| * x == * item) ?;
1707
1713
Some ( self . remove ( pos) )
1708
1714
}
1715
+
1709
1716
}
1710
1717
1711
1718
////////////////////////////////////////////////////////////////////////////////
You can’t perform that action at this time.
0 commit comments