Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Add <*{const|mut} T>::{to|from}_bits #91127

Merged
merged 2 commits into from
Dec 11, 2021
Merged

Conversation

scottmcm
Copy link
Member

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

Named based on the floating-point methods of the same name, as those are also about returning the *representation* of the value.
@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Nov 22, 2021
@rust-log-analyzer

This comment has been minimized.

@apiraino apiraino added the T-libs Relevant to the library team, which will review and decide on the PR/issue. label Nov 22, 2021
@oli-obk
Copy link
Contributor

oli-obk commented Nov 23, 2021

cc @RalfJung some new methods for pointer casts. I see nothing language relevant, but you may still have input

@RalfJung
Copy link
Member

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).
Copy link
Member

@camelid camelid Nov 24, 2021

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.

Copy link
Member Author

@scottmcm scottmcm Nov 28, 2021

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`].

@dtolnay dtolnay added T-libs-api Relevant to the library API team, which will review and decide on the PR/issue. and removed T-libs Relevant to the library team, which will review and decide on the PR/issue. labels Dec 10, 2021
@dtolnay dtolnay assigned dtolnay and unassigned joshtriplett Dec 10, 2021
Copy link
Member

@dtolnay dtolnay left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice!

@dtolnay
Copy link
Member

dtolnay commented Dec 10, 2021

@bors r+

@bors
Copy link
Contributor

bors commented Dec 10, 2021

📌 Commit 348a250 has been approved by dtolnay

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Dec 10, 2021
bors added a commit to rust-lang-ci/rust that referenced this pull request Dec 11, 2021
…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
@bors bors merged commit 2f8e2ff into rust-lang:master Dec 11, 2021
@rustbot rustbot added this to the 1.59.0 milestone Dec 11, 2021
@scottmcm scottmcm deleted the ptr_to_from_bits branch December 11, 2021 20:44
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-libs-api Relevant to the library API team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.