-
-
Notifications
You must be signed in to change notification settings - Fork 723
feat(allocator): add Box::as_non_null method
#15321
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
feat(allocator): add Box::as_non_null method
#15321
Conversation
How to use the Graphite Merge QueueAdd either label to this PR to merge it via the merge queue:
You must have a Graphite account in order to use the merge queue. Sign up using this link. An organization admin has enabled the Graphite Merge Queue in this repository. Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue. This stack of pull requests is managed by Graphite. Learn more about stacking. |
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.
Pull Request Overview
This PR adds a new method as_non_null to the Box type that provides a non-consuming way to obtain a NonNull pointer to the box's contents.
Key Changes:
- Added
Box::as_non_nullmethod that takes a reference to a Box and returns a NonNull pointer
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
CodSpeed Performance ReportMerging #15321 will not alter performanceComparing Summary
Footnotes |
d806f3c to
f42e703
Compare
Merge activity
|
Add a method `Box::as_non_null` which returns a `NonNull` pointer to the `Box`'s contents. Implemented as a static method `Box::as_non_null(boxed)` instead of `boxed.as_non_null()`, to avoid clashing with any `as_non_null` method on `T`, available via deref. This pattern follows stdlib.
f42e703 to
1274291
Compare
#15322) Use `Box::as_non_null` method (added in #15321) to ensure that creating an `Address` from a `Box`, no intermediate reference to the contents of the `Box` is created. This is important in `Traverse` which has tight aliasing constraints. Possibly `addr_of!` macro we used previously already ensured this, but I'm not 100% sure due to the double deref (`**`). Using `Box::as_non_null` is unambiguously safe.
f93b292 to
4114c3b
Compare
Add a method `Box::as_non_null` which returns a `NonNull` pointer to the `Box`'s contents. Implemented as a static method `Box::as_non_null(boxed)` instead of `boxed.as_non_null()`, to avoid clashing with any `as_non_null` method on `T`, available via deref. This pattern follows stdlib.
4114c3b to
b401708
Compare
#15322) Use `Box::as_non_null` method (added in #15321) to ensure that creating an `Address` from a `Box`, no intermediate reference to the contents of the `Box` is created. This is important in `Traverse` which has tight aliasing constraints. Possibly `addr_of!` macro we used previously already ensured this, but I'm not 100% sure due to the double deref (`**`). Using `Box::as_non_null` is unambiguously safe.

Add a method
Box::as_non_nullwhich returns aNonNullpointer to theBox's contents.Implemented as a static method
Box::as_non_null(boxed)instead ofboxed.as_non_null(), to avoid clashing with anyas_non_nullmethod onT, available via deref. This pattern follows stdlib.