@@ -397,6 +397,7 @@ impl<BorrowType, K, V, Type> NodeRef<BorrowType, K, V, Type> {
397
397
398
398
/// Borrows a view into the values stored in the node.
399
399
/// The caller must ensure that the node is not the shared root.
400
+ /// This function is not public, so doesn't have to support shared roots like `keys` does.
400
401
fn vals ( & self ) -> & [ V ] {
401
402
self . reborrow ( ) . into_val_slice ( )
402
403
}
@@ -514,6 +515,7 @@ impl<'a, K, V, Type> NodeRef<marker::Mut<'a>, K, V, Type> {
514
515
}
515
516
516
517
/// The caller must ensure that the node is not the shared root.
518
+ /// This function is not public, so doesn't have to support shared roots like `keys` does.
517
519
fn keys_mut ( & mut self ) -> & mut [ K ] {
518
520
unsafe { self . reborrow_mut ( ) . into_key_slice_mut ( ) }
519
521
}
@@ -589,20 +591,15 @@ impl<'a, K: 'a, V: 'a, Type> NodeRef<marker::Mut<'a>, K, V, Type> {
589
591
unsafe { & mut * ( self . root as * mut Root < K , V > ) }
590
592
}
591
593
594
+ /// The caller must ensure that the node is not the shared root.
592
595
fn into_key_slice_mut ( mut self ) -> & ' a mut [ K ] {
593
- // Same as for `into_key_slice` above, we try to avoid a run-time check.
594
- if ( mem:: align_of :: < NodeHeader < K , V , K > > ( ) > mem:: align_of :: < NodeHeader < K , V > > ( )
595
- || mem:: size_of :: < NodeHeader < K , V , K > > ( ) != mem:: size_of :: < NodeHeader < K , V > > ( ) )
596
- && self . is_shared_root ( )
597
- {
598
- & mut [ ]
599
- } else {
600
- unsafe {
601
- slice:: from_raw_parts_mut (
602
- MaybeUninit :: first_ptr_mut ( & mut ( * self . as_leaf_mut ( ) ) . keys ) ,
603
- self . len ( ) ,
604
- )
605
- }
596
+ debug_assert ! ( !self . is_shared_root( ) ) ;
597
+ // We cannot be the shared root, so `as_leaf_mut` is okay.
598
+ unsafe {
599
+ slice:: from_raw_parts_mut (
600
+ MaybeUninit :: first_ptr_mut ( & mut ( * self . as_leaf_mut ( ) ) . keys ) ,
601
+ self . len ( ) ,
602
+ )
606
603
}
607
604
}
608
605
0 commit comments