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

Implement From<&[T]> and From<&mut [T]> for NonNull #69319

Closed
wants to merge 1 commit into from

Conversation

tspiteri
Copy link
Contributor

Closes #69316.

@rust-highfive
Copy link
Collaborator

r? @dtolnay

(rust_highfive has picked a reviewer for you, use r? to override)

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Feb 20, 2020
@Centril Centril added T-libs-api Relevant to the library API team, which will review and decide on the PR/issue. needs-fcp This change is insta-stable, so needs a completed FCP to proceed. relnotes Marks issues that should be documented in the release notes of the next release. labels Feb 20, 2020
@Centril Centril added this to the 1.43 milestone Feb 20, 2020
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.

I am not 100% sold on these. Would NonNull::from(slice).cast::<T>() be sufficient for your use case? It looks like that solution was missed in #69316.

@tspiteri
Copy link
Contributor Author

Yes, I had indeed missed that! NonNull::from(slice).cast::<T>() is even already sufficient for another case where I can now get *mut T from &[MaybeUninit<T>] safely.

@tspiteri
Copy link
Contributor Author

tspiteri commented Feb 24, 2020

Further, I'm now realizing this PR would make it necessary to qualify NonNull::from(slice) in the above example into NonNull::<[T]>::from(slice), so it could be doing more harm than good even if, strictly speaking, adding impls is not considered a breaking change.

@tspiteri tspiteri closed this Feb 24, 2020
@Centril Centril removed the relnotes Marks issues that should be documented in the release notes of the next release. label Mar 10, 2020
@Centril Centril removed this from the 1.43 milestone Mar 10, 2020
@tspiteri tspiteri deleted the nonnull_from_slice branch March 13, 2020 13:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs-fcp This change is insta-stable, so needs a completed FCP to proceed. S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. 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.

Feature request: From<&[T]> for NonNull<T>
4 participants