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> {
16881688 pub fn dedup ( & mut self ) {
16891689 self . dedup_by ( |a, b| a == b)
16901690 }
1691+ }
1692+
1693+ impl < T > Vec < T > {
16911694
16921695 /// Removes the first instance of `item` from the vector if the item exists.
16931696 ///
@@ -1701,11 +1704,15 @@ impl<T: PartialEq> Vec<T> {
17011704 ///
17021705 /// assert_eq!(vec, vec![2, 3, 1]);
17031706 /// ```
1707+
17041708 #[ 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+ {
17061712 let pos = self . iter ( ) . position ( |x| * x == * item) ?;
17071713 Some ( self . remove ( pos) )
17081714 }
1715+
17091716}
17101717
17111718////////////////////////////////////////////////////////////////////////////////
You can’t perform that action at this time.
0 commit comments