Skip to content

std: refactor explanation of NonNull #141946

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

xizheyin
Copy link
Contributor

@xizheyin xizheyin commented Jun 3, 2025

Fixes #141933

I cut out the excessive explanation and used an example to explain how to maintain invariance, but I think what is quoted in the rust reference in the document needs to be added with a more layman's explanation and example.

(I'm not sure if I deleted too much)

r? @workingjubilee

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-libs Relevant to the library team, which will review and decide on the PR/issue. labels Jun 3, 2025
Streamlined the explanation of covariance for `NonNull<T>`,
focusing on practical usage and reducing scary explanation.
Added a concise example for cases where invariance is required,
showing how to use `PhantomData<Cell<T>>

Signed-off-by: xizheyin <[email protected]>
@xizheyin
Copy link
Contributor Author

xizheyin commented Jun 3, 2025

I've avoided big changes this time, removing some of the “scary” descriptions and replacing them with more practical advice, and adding more specific explanations for the examples.

@xizheyin xizheyin requested a review from workingjubilee June 9, 2025 05:27
@workingjubilee
Copy link
Member

workingjubilee commented Jun 11, 2025

Hm. I know I filed the issues but I wasn't really expecting to get two PRs immediately and requested on them, I kinda expected them to hit the rotation, and this is a slightly more tricky PR to judge when biased by being the reporter. So I'm going to pass them onto the rotation, sorry! ^^;

r? libs

@rustbot
Copy link
Collaborator

rustbot commented Jun 11, 2025

Failed to set assignee to 'd: invalid assignee

Note: Only org members with at least the repository "read" role, users with write permissions, or people who have commented on the PR may be assigned.

@rustbot rustbot assigned thomcc and unassigned workingjubilee Jun 11, 2025
@workingjubilee
Copy link
Member

lol
r? libs

@rustbot rustbot assigned jhpratt and unassigned thomcc Jun 11, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-libs Relevant to the library team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Reexplain NonNull's covariance details more concisely
5 participants