rust-lang / rust-lang/rust-by-example
Section needs more explanation
Nobody has claimed this yet.
- Dominant language
- Handlebars
- Stars
- 8.1k
- Forks
- 1.6k
- PR merge metrics
- No merged PRs in 30d
Description
On the page Option Result, the last example doesn't really have an explanation for the new combinators introduced. Namely, map_or.
Also, within the map_or, there is a closure function with no real explanation either.
|r| r.map(Some)
I don't really understand what is going on here.
The main line that needs explanation is
let opt = opt.map_or(Ok(None), |r| r.map(Some))?;
Like, what exactly is happening here? I've been staring at it for about 15 minutes, but I can't figure it out.
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 with the linked Option Result page and read the final example containing map_or, |r| r.map(Some), and the ? operator. Add explanations for the new combinator, the closure, and the full statement so readers can follow each transformation; the page should make the example understandable without additional context.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- documentation
- Issue type
- Documentation
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 45/100