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
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
3 participants