@@ -315,7 +315,7 @@ impl<BorrowType: marker::BorrowType, K, V, Type> NodeRef<BorrowType, K, V, Type>
315
315
pub fn ascend (
316
316
self ,
317
317
) -> Result < Handle < NodeRef < BorrowType , K , V , marker:: Internal > , marker:: Edge > , Self > {
318
- assert ! ( BorrowType :: PERMITS_TRAVERSAL ) ;
318
+ let _ = BorrowType :: TRAVERSAL_PERMIT ;
319
319
// We need to use raw pointers to nodes because, if BorrowType is marker::ValMut,
320
320
// there might be outstanding mutable references to values that we must not invalidate.
321
321
let leaf_ptr: * const _ = Self :: as_leaf_ptr ( & self ) ;
@@ -986,7 +986,7 @@ impl<BorrowType: marker::BorrowType, K, V>
986
986
/// `edge.descend().ascend().unwrap()` and `node.ascend().unwrap().descend()` should
987
987
/// both, upon success, do nothing.
988
988
pub fn descend ( self ) -> NodeRef < BorrowType , K , V , marker:: LeafOrInternal > {
989
- assert ! ( BorrowType :: PERMITS_TRAVERSAL ) ;
989
+ let _ = BorrowType :: TRAVERSAL_PERMIT ;
990
990
// We need to use raw pointers to nodes because, if BorrowType is
991
991
// marker::ValMut, there might be outstanding mutable references to
992
992
// values that we must not invalidate. There's no worry accessing the
@@ -1637,15 +1637,17 @@ pub mod marker {
1637
1637
pub struct ValMut < ' a > ( PhantomData < & ' a mut ( ) > ) ;
1638
1638
1639
1639
pub trait BorrowType {
1640
- // Whether node references of this borrow type allow traversing
1641
- // to other nodes in the tree.
1642
- const PERMITS_TRAVERSAL : bool = true ;
1640
+ // If node references of this borrow type allow traversing to other
1641
+ // nodes in the tree, this constant can be evaluated. Thus reading it
1642
+ // serves as a compile-time assertion.
1643
+ const TRAVERSAL_PERMIT : ( ) = ( ) ;
1643
1644
}
1644
1645
impl BorrowType for Owned {
1645
- // Traversal isn't needed, it happens using the result of `borrow_mut`.
1646
+ // Reject evaluation, because traversal isn't needed. Instead traversal
1647
+ // happens using the result of `borrow_mut`.
1646
1648
// By disabling traversal, and only creating new references to roots,
1647
1649
// we know that every reference of the `Owned` type is to a root node.
1648
- const PERMITS_TRAVERSAL : bool = false ;
1650
+ const TRAVERSAL_PERMIT : ( ) = panic ! ( ) ;
1649
1651
}
1650
1652
impl BorrowType for Dying { }
1651
1653
impl < ' a > BorrowType for Immut < ' a > { }
0 commit comments