@@ -47,14 +47,12 @@ impl<'a, K, V> LeafRange<marker::Immut<'a>, K, V> {
47
47
48
48
#[ inline]
49
49
pub unsafe fn next_unchecked ( & mut self ) -> ( & ' a K , & ' a V ) {
50
- debug_assert ! ( self . front. is_some( ) ) ;
51
- unsafe { self . front . as_mut ( ) . unwrap_unchecked ( ) . next_unchecked ( ) }
50
+ unsafe { self . front . as_mut ( ) . unwrap ( ) . next_unchecked ( ) }
52
51
}
53
52
54
53
#[ inline]
55
54
pub unsafe fn next_back_unchecked ( & mut self ) -> ( & ' a K , & ' a V ) {
56
- debug_assert ! ( self . back. is_some( ) ) ;
57
- unsafe { self . back . as_mut ( ) . unwrap_unchecked ( ) . next_back_unchecked ( ) }
55
+ unsafe { self . back . as_mut ( ) . unwrap ( ) . next_back_unchecked ( ) }
58
56
}
59
57
}
60
58
@@ -71,14 +69,12 @@ impl<'a, K, V> LeafRange<marker::ValMut<'a>, K, V> {
71
69
72
70
#[ inline]
73
71
pub unsafe fn next_unchecked ( & mut self ) -> ( & ' a K , & ' a mut V ) {
74
- debug_assert ! ( self . front. is_some( ) ) ;
75
- unsafe { self . front . as_mut ( ) . unwrap_unchecked ( ) . next_unchecked ( ) }
72
+ unsafe { self . front . as_mut ( ) . unwrap ( ) . next_unchecked ( ) }
76
73
}
77
74
78
75
#[ inline]
79
76
pub unsafe fn next_back_unchecked ( & mut self ) -> ( & ' a K , & ' a mut V ) {
80
- debug_assert ! ( self . back. is_some( ) ) ;
81
- unsafe { self . back . as_mut ( ) . unwrap_unchecked ( ) . next_back_unchecked ( ) }
77
+ unsafe { self . back . as_mut ( ) . unwrap ( ) . next_back_unchecked ( ) }
82
78
}
83
79
}
84
80
@@ -400,9 +396,7 @@ impl<'a, K, V> Handle<NodeRef<marker::Immut<'a>, K, V, marker::Leaf>, marker::Ed
400
396
/// There must be another KV in the direction travelled.
401
397
unsafe fn next_unchecked ( & mut self ) -> ( & ' a K , & ' a V ) {
402
398
super :: mem:: replace ( self , |leaf_edge| {
403
- let kv = leaf_edge. next_kv ( ) ;
404
- debug_assert ! ( kv. is_ok( ) ) ;
405
- let kv = unsafe { kv. ok ( ) . unwrap_unchecked ( ) } ;
399
+ let kv = leaf_edge. next_kv ( ) . ok ( ) . unwrap ( ) ;
406
400
( kv. next_leaf_edge ( ) , kv. into_kv ( ) )
407
401
} )
408
402
}
@@ -414,9 +408,7 @@ impl<'a, K, V> Handle<NodeRef<marker::Immut<'a>, K, V, marker::Leaf>, marker::Ed
414
408
/// There must be another KV in the direction travelled.
415
409
unsafe fn next_back_unchecked ( & mut self ) -> ( & ' a K , & ' a V ) {
416
410
super :: mem:: replace ( self , |leaf_edge| {
417
- let kv = leaf_edge. next_back_kv ( ) ;
418
- debug_assert ! ( kv. is_ok( ) ) ;
419
- let kv = unsafe { kv. ok ( ) . unwrap_unchecked ( ) } ;
411
+ let kv = leaf_edge. next_back_kv ( ) . ok ( ) . unwrap ( ) ;
420
412
( kv. next_back_leaf_edge ( ) , kv. into_kv ( ) )
421
413
} )
422
414
}
@@ -430,9 +422,7 @@ impl<'a, K, V> Handle<NodeRef<marker::ValMut<'a>, K, V, marker::Leaf>, marker::E
430
422
/// There must be another KV in the direction travelled.
431
423
unsafe fn next_unchecked ( & mut self ) -> ( & ' a K , & ' a mut V ) {
432
424
let kv = super :: mem:: replace ( self , |leaf_edge| {
433
- let kv = leaf_edge. next_kv ( ) ;
434
- debug_assert ! ( kv. is_ok( ) ) ;
435
- let kv = unsafe { kv. ok ( ) . unwrap_unchecked ( ) } ;
425
+ let kv = leaf_edge. next_kv ( ) . ok ( ) . unwrap ( ) ;
436
426
( unsafe { ptr:: read ( & kv) } . next_leaf_edge ( ) , kv)
437
427
} ) ;
438
428
// Doing this last is faster, according to benchmarks.
@@ -446,9 +436,7 @@ impl<'a, K, V> Handle<NodeRef<marker::ValMut<'a>, K, V, marker::Leaf>, marker::E
446
436
/// There must be another KV in the direction travelled.
447
437
unsafe fn next_back_unchecked ( & mut self ) -> ( & ' a K , & ' a mut V ) {
448
438
let kv = super :: mem:: replace ( self , |leaf_edge| {
449
- let kv = leaf_edge. next_back_kv ( ) ;
450
- debug_assert ! ( kv. is_ok( ) ) ;
451
- let kv = unsafe { kv. ok ( ) . unwrap_unchecked ( ) } ;
439
+ let kv = leaf_edge. next_back_kv ( ) . ok ( ) . unwrap ( ) ;
452
440
( unsafe { ptr:: read ( & kv) } . next_back_leaf_edge ( ) , kv)
453
441
} ) ;
454
442
// Doing this last is faster, according to benchmarks.
@@ -472,9 +460,7 @@ impl<K, V> Handle<NodeRef<marker::Dying, K, V, marker::Leaf>, marker::Edge> {
472
460
pub unsafe fn deallocating_next_unchecked (
473
461
& mut self ,
474
462
) -> Handle < NodeRef < marker:: Dying , K , V , marker:: LeafOrInternal > , marker:: KV > {
475
- super :: mem:: replace ( self , |leaf_edge| unsafe {
476
- leaf_edge. deallocating_next ( ) . unwrap_unchecked ( )
477
- } )
463
+ super :: mem:: replace ( self , |leaf_edge| unsafe { leaf_edge. deallocating_next ( ) . unwrap ( ) } )
478
464
}
479
465
480
466
/// Moves the leaf edge handle to the previous leaf edge and returns the key and value
@@ -493,7 +479,7 @@ impl<K, V> Handle<NodeRef<marker::Dying, K, V, marker::Leaf>, marker::Edge> {
493
479
& mut self ,
494
480
) -> Handle < NodeRef < marker:: Dying , K , V , marker:: LeafOrInternal > , marker:: KV > {
495
481
super :: mem:: replace ( self , |leaf_edge| unsafe {
496
- leaf_edge. deallocating_next_back ( ) . unwrap_unchecked ( )
482
+ leaf_edge. deallocating_next_back ( ) . unwrap ( )
497
483
} )
498
484
}
499
485
}
0 commit comments