diff --git a/library/alloc/src/collections/btree/node.rs b/library/alloc/src/collections/btree/node.rs index 4fc32305f1e30..dc99f33da19aa 100644 --- a/library/alloc/src/collections/btree/node.rs +++ b/library/alloc/src/collections/btree/node.rs @@ -461,7 +461,7 @@ impl NodeRef { } } -impl<'a, K, V, Type> NodeRef, K, V, Type> { +impl<'a, K, V> NodeRef, K, V, marker::LeafOrInternal> { /// Unsafely asserts to the compiler the static information that this node is a `Leaf`. unsafe fn cast_to_leaf_unchecked(self) -> NodeRef, K, V, marker::Leaf> { debug_assert!(self.height == 0); @@ -473,7 +473,9 @@ impl<'a, K, V, Type> NodeRef, K, V, Type> { debug_assert!(self.height > 0); NodeRef { height: self.height, node: self.node, _marker: PhantomData } } +} +impl<'a, K, V, Type> NodeRef, K, V, Type> { /// Temporarily takes out another, mutable reference to the same node. Beware, as /// this method is very dangerous, doubly so since it may not immediately appear /// dangerous. @@ -761,15 +763,17 @@ impl } } -impl<'a, K, V, NodeType, HandleType> Handle, K, V, NodeType>, HandleType> { +impl<'a, K, V, Type> Handle, K, V, marker::LeafOrInternal>, Type> { /// Unsafely asserts to the compiler the static information that the handle's node is a `Leaf`. pub unsafe fn cast_to_leaf_unchecked( self, - ) -> Handle, K, V, marker::Leaf>, HandleType> { + ) -> Handle, K, V, marker::Leaf>, Type> { let node = unsafe { self.node.cast_to_leaf_unchecked() }; Handle { node, idx: self.idx, _marker: PhantomData } } +} +impl<'a, K, V, NodeType, HandleType> Handle, K, V, NodeType>, HandleType> { /// Temporarily takes out another, mutable handle on the same location. Beware, as /// this method is very dangerous, doubly so since it may not immediately appear /// dangerous. @@ -1519,15 +1523,13 @@ impl Handle, marke } } -impl - Handle, HandleType> -{ +impl Handle, Type> { /// Checks whether the underlying node is an `Internal` node or a `Leaf` node. pub fn force( self, ) -> ForceResult< - Handle, HandleType>, - Handle, HandleType>, + Handle, Type>, + Handle, Type>, > { match self.node.force() { ForceResult::Leaf(node) => {