-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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
Add <*{const|mut} T>::{to|from}_bits
#91127
Conversation
Named based on the floating-point methods of the same name, as those are also about returning the *representation* of the value.
This comment has been minimized.
This comment has been minimized.
cc @RalfJung some new methods for pointer casts. I see nothing language relevant, but you may still have input |
Makes sense to me. In the future these methods doc comments would probably be a good place to discuss the finer details of how pointer provenance interacts with ptr-int-ptr roundtrips. |
@@ -78,7 +78,7 @@ impl<T: ?Sized> *mut T { | |||
/// Creates a pointer from its raw bits. | |||
/// | |||
/// This is equivalent to `as *mut T`, but is more specific to enhance readability. | |||
/// The inverse method is [`Self::to_bits`]. | |||
/// The inverse method is [`to_bits`](#method.to_bits-1). |
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.
Note that the number disambiguates between *const
and *mut
, though I don't know if the number is stable. If you don't want to disambiguate, you can also use [`to_bits`](pointer::to_bits)
as an intra-doc link.
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 also don't know if it's stable. I put it this way as it worked locally in x.py doc
. Based on the zulip conversation there's no great solution right now, so I think I'll just leave it like this. Hopefully one day it can go back to just [`Self::to_bits`]
.
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.
Nice!
@bors r+ |
📌 Commit 348a250 has been approved by |
…askrgr Rollup of 6 pull requests Successful merges: - rust-lang#91127 (Add `<*{const|mut} T>::{to|from}_bits`) - rust-lang#91310 (Add --out-dir flag for rustdoc) - rust-lang#91373 (Add needs-unwind to tests that depend on panicking) - rust-lang#91426 (Make IdFunctor::try_map_id panic-safe) - rust-lang#91515 (Add rsplit_array variants to slices and arrays) - rust-lang#91553 (socket ancillary data implementation for dragonflybsd.) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
Named based on the floating-point methods of the same name, as those are also about returning the representation of the value.
Tracking issue: #91126
Based on the conversation in https://rust-lang.zulipchat.com/#narrow/stream/219381-t-libs/topic/Adding.20methods.20as.20more.20specific.20versions.20of.20.60as.60/near/238391074
r? @joshtriplett