Skip to content
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

is_aligned method for pointers #56304

Closed
Lokathor opened this issue Nov 28, 2018 · 4 comments
Closed

is_aligned method for pointers #56304

Lokathor opened this issue Nov 28, 2018 · 4 comments
Labels
C-feature-request Category: A feature request, i.e: not implemented / a PR. T-libs-api Relevant to the library API team, which will review and decide on the PR/issue.

Comments

@Lokathor
Copy link
Contributor

Lokathor commented Nov 28, 2018

Just a quick request for an is_aligned method to be on pointers so that we can have an official way to check alignment.

@Centril Centril added T-libs-api Relevant to the library API team, which will review and decide on the PR/issue. C-feature-request Category: A feature request, i.e: not implemented / a PR. labels Nov 28, 2018
@scottmcm
Copy link
Member

scottmcm commented Dec 3, 2018

This was talked about a bunch in rust-lang/rfcs#2043

If you're ok with false-negatives, you can just use .align_offset() == 0.

@Lokathor
Copy link
Contributor Author

Lokathor commented Dec 4, 2018

But you actually need to pass in an alignment, so you also need to make sure that the alignment you pass is correct for the type that the pointer currently is. And even after that difficulty you don't get an assured answer. That seems a lot less good.

@saethlin
Copy link
Member

I think this is taken care of by #96284

@m-ou-se
Copy link
Member

m-ou-se commented Sep 20, 2022

Closing because of #96284

@m-ou-se m-ou-se closed this as completed Sep 20, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-feature-request Category: A feature request, i.e: not implemented / a PR. T-libs-api Relevant to the library API team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

5 participants