Subpar documentation for ptr-to-ref conversion methods
Open
@lolbinarycat is already working on this.
Since Jun 9, 2024.
A-docs
A-doctests
C-discussion
C-enhancement
E-help-wanted
T-libs
- Dominant language
- Rust
- Stars
- 119k
- Forks
- 16.1k
- PR merge metrics
- PR metrics pending
Description
While trying to merge #122492, some issues with the existing documentation became apparent.
The methods in question
-
<*const T>::as_ref -
<*mut T>::as_ref -
<*mut T>::as_mut -
<*const T>::as_ref_unchecked[^unchecked] -
<*mut T>::as_ref_unchecked[^unchecked] -
<*mut T>::as_mut_unchecked[^unchecked] -
<*const T>::as_uninit_ref[^uninit] -
<*mut T>::as_uninit_ref[^uninit] -
<*mut T>::as_uninit_mut[^uninit]
[^unchecked]: Not yet stabilized (#122034)
[^uninit]: Not yet stabilized (#75402)
The problems
- The overarching pain-point is that big parts of documentation are repeated for all (or at least the most) of the methods, which makes it difficult to keep the wording in sync.
Documentation
- Generally subpar wording (probably due to these docs' being a patchwork of many separate changes). But also specifically:
- Imprecise wording around
UnsafeCell -
Needlessly scary wording around the output's lifetimeOr not?
Doctests
-
Currently, they do printing instead of asserting. This should probably be changed to assertions.(Fixed in #126210) - The assertions that we want should reflect the API being tested. (For example, we probably want an assertion that null pointer gets converted to
Noneforas_ref, but no such assertion foras_ref_uncheckedis possible.) - Currently some asserts are hidden. Why?
Moving forward
Feel free to voice your opinions/wishes/suggestions/questions regarding this issue or to submit PRs addressing any of the problems above (not necessarily all at once). Also, doctests can probably be worked on independently from the documentation itself.
Beep-Boop
@rustbot label +A-docs +A-doctests +C-discussion +C-enhancement +E-help-wanted
And now footnotes:
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.