Subtyping and Variance - Trait variance not covered
Nobody has claimed this yet.
- Dominant language
- CSS
- Stars
- 2.3k
- Forks
- 325
- PR merge metrics
- No merged PRs in 30d
Description
I ran into an issue with variance & subtyping, so I started to investigate about the topic. I read Rustnomicon's page about it, the reference, and watched Jon Gjengset's video, and I finally understood it, more or less. However, I still couldn't tell why my specific issue was occurring, because the examples covered in these sources were quite basic.
I only discovered why I was running into that issue once I stumbled upon some section in Rust's developer book. It mentions that "traits with associated types must be invariant with respect to all of their inputs", which is exactly my case. But to learn this, I had to look through a book that should only be used by those that contribute to the Rust compiler.
It would be really nice if it was included in the Rustnomicon (or maybe in the reference, or both). Furthermore, the explanation in Rust's developer book uses compiler terminology and implementation-specific stuff that I'm not familiar with. To this day, I only know that these traits are invariant, but not really why.
Thanks in advance!
Contributor guide
No contributing guide indexed for this repository
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 Rustnomicon subtyping page and compare its coverage with the Rust Reference and the Rust compiler development guide section on variance and associated types. Document why traits with associated types are invariant, using terminology suitable for Rust users, and ensure the relevant Rustonomicon or Reference section explains the reported case.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- documentation
- Issue type
- Documentation
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100