File tree Expand file tree Collapse file tree 2 files changed +5
-5
lines changed Expand file tree Collapse file tree 2 files changed +5
-5
lines changed Original file line number Diff line number Diff line change @@ -2572,13 +2572,13 @@ pub trait Iterator {
25722572 /// ```
25732573 #[ inline]
25742574 #[ unstable( feature = "is_sorted" , reason = "new API" , issue = "53485" ) ]
2575- fn is_sorted_by_key < F , K > ( self , mut f : F ) -> bool
2575+ fn is_sorted_by_key < F , K > ( self , f : F ) -> bool
25762576 where
25772577 Self : Sized ,
2578- F : FnMut ( & Self :: Item ) -> K ,
2578+ F : FnMut ( Self :: Item ) -> K ,
25792579 K : PartialOrd
25802580 {
2581- self . is_sorted_by ( |a , b| f ( a ) . partial_cmp ( & f ( b ) ) )
2581+ self . map ( f ) . is_sorted ( )
25822582 }
25832583}
25842584
Original file line number Diff line number Diff line change @@ -2459,12 +2459,12 @@ impl<T> [T] {
24592459 /// ```
24602460 #[ inline]
24612461 #[ unstable( feature = "is_sorted" , reason = "new API" , issue = "53485" ) ]
2462- pub fn is_sorted_by_key < F , K > ( & self , mut f : F ) -> bool
2462+ pub fn is_sorted_by_key < F , K > ( & self , f : F ) -> bool
24632463 where
24642464 F : FnMut ( & T ) -> K ,
24652465 K : PartialOrd
24662466 {
2467- self . is_sorted_by ( |a , b| f ( a ) . partial_cmp ( & f ( b ) ) )
2467+ self . iter ( ) . is_sorted_by_key ( f )
24682468 }
24692469}
24702470
You can’t perform that action at this time.
0 commit comments