make std docs much more pedantically clear about primitive operators
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 119k
- Forks
- 16.1k
- PR merge metrics
- PR metrics pending
Description
Location
vaguely gestures to std's docs in general
Summary
Many operator/trait impls in std are undocumented. Most of the time this is basically fine, but for some things this is a lost opportunity to mention a trait's subtle/important semantics. For maintenance/noise reasons, these docs should be fairly short and prefer linking more verbose/detailed unified documentation on the subject in interest.
e.g. See the the docs on [integer overflow](some-link-to-central-docs) or something similarly brief.
To get started, the primitive types and their operators are great candidates. They don't at all mention overflow semantics, and it's up to the user to figure it out themselves by googling for rust overflow. Similarly for the flavours of shifts/division/modulo.
The reference does have a great page for std to link way more aggressively, although it could merit some more details, more accessible language, more examples, etc. There's also these docs in TRPL.
Otherwise if the reference wants to be kept at its current level of detail, we could repurpose the otherwise empty module docs in num or maybe ops.
I'm mildly inclined to have docs in num/ops because that feels like the more appropriate place to take the time to enumerate all the std APIs that do exist to fill in all the different approaches to overflow (panic, wrap, saturate, Option, ...), shift (logical, arithmetic, ...), div/rem (rounding direction, sign handling, ...), casts (truncate, zero-extend, sign-extend, panic, Option, ...). If we do follow this path then it should cross-link the reference and vice-versa.
I especially would love to see more time spent luxuriating in examples that really poke at the different corner cases in these solutions and how they differ in behaviour, which is often the easiest way to make everyone 100% confident we agree on which things have which behaviours.
I will happily mentor/review all work on this issue.
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.
Research direction
Start by comparing the primitive operator material in the Rust Reference operator-expr page with the core/num and core/ops documentation, then review the linked TRPL section. Define a focused scope for documenting overflow, shifts, division, modulo, and casts, with concise links and corner-case examples. Done means the selected APIs explain their semantics and cross-link consistently with the Reference.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- documentation
- Issue type
- Documentation
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100