@@ -318,7 +318,10 @@ impl<BorrowType: marker::BorrowType, K, V, Type> NodeRef<BorrowType, K, V, Type>
318
318
pub fn ascend (
319
319
self ,
320
320
) -> Result < Handle < NodeRef < BorrowType , K , V , marker:: Internal > , marker:: Edge > , Self > {
321
- let _ = BorrowType :: TRAVERSAL_PERMIT ;
321
+ const {
322
+ assert ! ( BorrowType :: TRAVERSAL_PERMIT ) ;
323
+ }
324
+
322
325
// We need to use raw pointers to nodes because, if BorrowType is marker::ValMut,
323
326
// there might be outstanding mutable references to values that we must not invalidate.
324
327
let leaf_ptr: * const _ = Self :: as_leaf_ptr ( & self ) ;
@@ -1003,7 +1006,10 @@ impl<BorrowType: marker::BorrowType, K, V>
1003
1006
/// `edge.descend().ascend().unwrap()` and `node.ascend().unwrap().descend()` should
1004
1007
/// both, upon success, do nothing.
1005
1008
pub fn descend ( self ) -> NodeRef < BorrowType , K , V , marker:: LeafOrInternal > {
1006
- let _ = BorrowType :: TRAVERSAL_PERMIT ;
1009
+ const {
1010
+ assert ! ( BorrowType :: TRAVERSAL_PERMIT ) ;
1011
+ }
1012
+
1007
1013
// We need to use raw pointers to nodes because, if BorrowType is
1008
1014
// marker::ValMut, there might be outstanding mutable references to
1009
1015
// values that we must not invalidate. There's no worry accessing the
@@ -1666,17 +1672,17 @@ pub mod marker {
1666
1672
pub struct ValMut < ' a > ( PhantomData < & ' a mut ( ) > ) ;
1667
1673
1668
1674
pub trait BorrowType {
1669
- // If node references of this borrow type allow traversing to other
1670
- // nodes in the tree, this constant can be evaluated. Thus reading it
1671
- // serves as a compile-time assertion.
1672
- const TRAVERSAL_PERMIT : ( ) = ( ) ;
1675
+ /// If node references of this borrow type allow traversing to other
1676
+ /// nodes in the tree, this constant is set to `true`. It can be used
1677
+ /// for a compile-time assertion.
1678
+ const TRAVERSAL_PERMIT : bool = true ;
1673
1679
}
1674
1680
impl BorrowType for Owned {
1675
- // Reject evaluation , because traversal isn't needed. Instead traversal
1676
- // happens using the result of `borrow_mut`.
1677
- // By disabling traversal, and only creating new references to roots,
1678
- // we know that every reference of the `Owned` type is to a root node.
1679
- const TRAVERSAL_PERMIT : ( ) = panic ! ( ) ;
1681
+ /// Reject traversal , because it isn't needed. Instead traversal
1682
+ /// happens using the result of `borrow_mut`.
1683
+ /// By disabling traversal, and only creating new references to roots,
1684
+ /// we know that every reference of the `Owned` type is to a root node.
1685
+ const TRAVERSAL_PERMIT : bool = false ;
1680
1686
}
1681
1687
impl BorrowType for Dying { }
1682
1688
impl < ' a > BorrowType for Immut < ' a > { }
0 commit comments