Skip to content

Commit 240ef70

Browse files
committed
Define forget_type only when relevant
1 parent e614f66 commit 240ef70

File tree

2 files changed

+16
-8
lines changed

2 files changed

+16
-8
lines changed

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

+2-2
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ impl<BorrowType, K, V> Handle<NodeRef<BorrowType, K, V, marker::Leaf>, marker::E
1919
Ok(internal_kv) => return Ok(internal_kv),
2020
Err(last_edge) => match last_edge.into_node().ascend() {
2121
Ok(parent_edge) => parent_edge.forget_node_type(),
22-
Err(root) => return Err(root.forget_type()),
22+
Err(root) => return Err(root),
2323
},
2424
}
2525
}
@@ -40,7 +40,7 @@ impl<BorrowType, K, V> Handle<NodeRef<BorrowType, K, V, marker::Leaf>, marker::E
4040
Ok(internal_kv) => return Ok(internal_kv),
4141
Err(last_edge) => match last_edge.into_node().ascend() {
4242
Ok(parent_edge) => parent_edge.forget_node_type(),
43-
Err(root) => return Err(root.forget_type()),
43+
Err(root) => return Err(root),
4444
},
4545
}
4646
}

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

+14-6
Original file line numberDiff line numberDiff line change
@@ -305,12 +305,6 @@ impl<BorrowType, K, V, Type> NodeRef<BorrowType, K, V, Type> {
305305
self.height
306306
}
307307

308-
/// Removes any static information about whether this node is a `Leaf` or an
309-
/// `Internal` node.
310-
pub fn forget_type(self) -> NodeRef<BorrowType, K, V, marker::LeafOrInternal> {
311-
NodeRef { height: self.height, node: self.node, root: self.root, _marker: PhantomData }
312-
}
313-
314308
/// Temporarily takes out another, immutable reference to the same node.
315309
fn reborrow(&self) -> NodeRef<marker::Immut<'_>, K, V, Type> {
316310
NodeRef { height: self.height, node: self.node, root: self.root, _marker: PhantomData }
@@ -1362,6 +1356,20 @@ unsafe fn move_edges<K, V>(
13621356
}
13631357
}
13641358

1359+
impl<BorrowType, K, V> NodeRef<BorrowType, K, V, marker::Leaf> {
1360+
/// Removes any static information asserting that this node is a `Leaf` node.
1361+
pub fn forget_type(self) -> NodeRef<BorrowType, K, V, marker::LeafOrInternal> {
1362+
NodeRef { height: self.height, node: self.node, root: self.root, _marker: PhantomData }
1363+
}
1364+
}
1365+
1366+
impl<BorrowType, K, V> NodeRef<BorrowType, K, V, marker::Internal> {
1367+
/// Removes any static information asserting that this node is an `Internal` node.
1368+
pub fn forget_type(self) -> NodeRef<BorrowType, K, V, marker::LeafOrInternal> {
1369+
NodeRef { height: self.height, node: self.node, root: self.root, _marker: PhantomData }
1370+
}
1371+
}
1372+
13651373
impl<BorrowType, K, V> Handle<NodeRef<BorrowType, K, V, marker::Leaf>, marker::Edge> {
13661374
pub fn forget_node_type(
13671375
self,

0 commit comments

Comments
 (0)