diff options
| author | Stuart Cook <Zalathar@users.noreply.github.com> | 2025-09-22 20:25:16 +1000 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-09-22 20:25:16 +1000 |
| commit | 8cf94b6c82bb65775f6cf74b8f705a98ca36b5ac (patch) | |
| tree | 58c15158365566706cedefda1381a21ee76b6654 | |
| parent | 7b6553c7462b4f3b933522ff356a92efbae2dc03 (diff) | |
| parent | 2dfcd0948e0dc1608a04e35d2f1812a21cf45b7a (diff) | |
| download | rust-8cf94b6c82bb65775f6cf74b8f705a98ca36b5ac.tar.gz rust-8cf94b6c82bb65775f6cf74b8f705a98ca36b5ac.zip | |
Rollup merge of #146846 - hkBst:btree-2, r=tgross35
btree InternalNode::new safety comments
| -rw-r--r-- | library/alloc/src/collections/btree/node.rs | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/library/alloc/src/collections/btree/node.rs b/library/alloc/src/collections/btree/node.rs index b233e1740b7..2b8103c8b77 100644 --- a/library/alloc/src/collections/btree/node.rs +++ b/library/alloc/src/collections/btree/node.rs @@ -117,10 +117,11 @@ impl<K, V> InternalNode<K, V> { /// initialized and valid edge. This function does not set up /// such an edge. unsafe fn new<A: Allocator + Clone>(alloc: A) -> Box<Self, A> { + let mut node = Box::<Self, _>::new_uninit_in(alloc); unsafe { - let mut node = Box::<Self, _>::new_uninit_in(alloc); - // We only need to initialize the data; the edges are MaybeUninit. + // SAFETY: argument points to the `node.data` `LeafNode` LeafNode::init(&raw mut (*node.as_mut_ptr()).data); + // SAFETY: `node.data` was just initialized and `node.edges` is MaybeUninit. node.assume_init() } } |
