-
Notifications
You must be signed in to change notification settings - Fork 12.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
BTreeMap: wrap node's raw parent pointer in NonNull #76929
Conversation
let parent_as_leaf = unsafe { (*self.as_leaf_ptr()).parent as *const LeafNode<K, V> }; | ||
if let Some(non_zero) = NonNull::new(parent_as_leaf as *mut _) { | ||
let leaf_ptr = self.as_leaf_ptr(); | ||
if let &Some(non_zero) = &unsafe { (*leaf_ptr).parent } { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hm, this looks a bit odd -- maybe we can drop the reference on both sides (in the pattern and before unsafe)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But then it's moved out of the option. Before this I had:
if let Some(non_zero) = unsafe { (*leaf_ptr).parent.as_ref() } {
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think I prefer the latter form, it looks clearer to me.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about this fancy one?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also straigthened out the conversions to usize.
66a16c9
to
0661b0a
Compare
@bors r+ rollup=never |
📌 Commit 0661b0a has been approved by |
☀️ Test successful - checks-actions, checks-azure |
Now that the other
*const
(root) is gone, seemed like a small step forward.r? @Mark-Simulacrum