File tree 1 file changed +4
-15
lines changed
library/alloc/src/collections
1 file changed +4
-15
lines changed Original file line number Diff line number Diff line change @@ -2516,24 +2516,13 @@ impl<T> VecDeque<T> {
2516
2516
where
2517
2517
F : FnMut ( & ' a T ) -> Ordering ,
2518
2518
{
2519
- if self . is_empty ( ) {
2520
- return Err ( 0 ) ;
2521
- }
2522
-
2523
2519
let ( front, back) = self . as_slices ( ) ;
2524
2520
2525
- match back. first ( ) . map ( |elem| f ( elem) ) {
2526
- Some ( Ordering :: Equal ) => return Ok ( front. len ( ) ) ,
2527
- Some ( Ordering :: Less ) => {
2528
- return back[ 1 ..]
2529
- . binary_search_by ( f)
2530
- . map ( |idx| idx + front. len ( ) + 1 )
2531
- . map_err ( |idx| idx + front. len ( ) + 1 ) ;
2532
- }
2533
- _ => { }
2521
+ if let Some ( Ordering :: Less | Ordering :: Equal ) = back. first ( ) . map ( |elem| f ( elem) ) {
2522
+ back. binary_search_by ( f) . map ( |idx| idx + front. len ( ) ) . map_err ( |idx| idx + front. len ( ) )
2523
+ } else {
2524
+ front. binary_search_by ( f)
2534
2525
}
2535
-
2536
- front. binary_search_by ( f)
2537
2526
}
2538
2527
2539
2528
/// Binary searches this sorted `VecDeque` with a key extraction function.
You can’t perform that action at this time.
0 commit comments