Skip to content

Commit 794561c

Browse files
committed
BTree: no longer define impossible casts
1 parent a4e595d commit 794561c

File tree

1 file changed

+10
-8
lines changed
  • library/alloc/src/collections/btree

1 file changed

+10
-8
lines changed

library/alloc/src/collections/btree/node.rs

+10-8
Original file line numberDiff line numberDiff line change
@@ -461,7 +461,7 @@ impl<K, V> NodeRef<marker::Dying, K, V, marker::LeafOrInternal> {
461461
}
462462
}
463463

464-
impl<'a, K, V, Type> NodeRef<marker::Mut<'a>, K, V, Type> {
464+
impl<'a, K, V> NodeRef<marker::Mut<'a>, K, V, marker::LeafOrInternal> {
465465
/// Unsafely asserts to the compiler the static information that this node is a `Leaf`.
466466
unsafe fn cast_to_leaf_unchecked(self) -> NodeRef<marker::Mut<'a>, K, V, marker::Leaf> {
467467
debug_assert!(self.height == 0);
@@ -473,7 +473,9 @@ impl<'a, K, V, Type> NodeRef<marker::Mut<'a>, K, V, Type> {
473473
debug_assert!(self.height > 0);
474474
NodeRef { height: self.height, node: self.node, _marker: PhantomData }
475475
}
476+
}
476477

478+
impl<'a, K, V, Type> NodeRef<marker::Mut<'a>, K, V, Type> {
477479
/// Temporarily takes out another, mutable reference to the same node. Beware, as
478480
/// this method is very dangerous, doubly so since it may not immediately appear
479481
/// dangerous.
@@ -761,15 +763,17 @@ impl<BorrowType, K, V, NodeType, HandleType>
761763
}
762764
}
763765

764-
impl<'a, K, V, NodeType, HandleType> Handle<NodeRef<marker::Mut<'a>, K, V, NodeType>, HandleType> {
766+
impl<'a, K, V, Type> Handle<NodeRef<marker::Mut<'a>, K, V, marker::LeafOrInternal>, Type> {
765767
/// Unsafely asserts to the compiler the static information that the handle's node is a `Leaf`.
766768
pub unsafe fn cast_to_leaf_unchecked(
767769
self,
768-
) -> Handle<NodeRef<marker::Mut<'a>, K, V, marker::Leaf>, HandleType> {
770+
) -> Handle<NodeRef<marker::Mut<'a>, K, V, marker::Leaf>, Type> {
769771
let node = unsafe { self.node.cast_to_leaf_unchecked() };
770772
Handle { node, idx: self.idx, _marker: PhantomData }
771773
}
774+
}
772775

776+
impl<'a, K, V, NodeType, HandleType> Handle<NodeRef<marker::Mut<'a>, K, V, NodeType>, HandleType> {
773777
/// Temporarily takes out another, mutable handle on the same location. Beware, as
774778
/// this method is very dangerous, doubly so since it may not immediately appear
775779
/// dangerous.
@@ -1519,15 +1523,13 @@ impl<BorrowType, K, V> Handle<NodeRef<BorrowType, K, V, marker::Internal>, marke
15191523
}
15201524
}
15211525

1522-
impl<BorrowType, K, V, HandleType>
1523-
Handle<NodeRef<BorrowType, K, V, marker::LeafOrInternal>, HandleType>
1524-
{
1526+
impl<BorrowType, K, V, Type> Handle<NodeRef<BorrowType, K, V, marker::LeafOrInternal>, Type> {
15251527
/// Checks whether the underlying node is an `Internal` node or a `Leaf` node.
15261528
pub fn force(
15271529
self,
15281530
) -> ForceResult<
1529-
Handle<NodeRef<BorrowType, K, V, marker::Leaf>, HandleType>,
1530-
Handle<NodeRef<BorrowType, K, V, marker::Internal>, HandleType>,
1531+
Handle<NodeRef<BorrowType, K, V, marker::Leaf>, Type>,
1532+
Handle<NodeRef<BorrowType, K, V, marker::Internal>, Type>,
15311533
> {
15321534
match self.node.force() {
15331535
ForceResult::Leaf(node) => {

0 commit comments

Comments
 (0)