Skip to content
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

Subtyping and Variance - Trait variance not covered #338

Open
marioortizmanero opened this issue Feb 9, 2022 · 0 comments
Open

Subtyping and Variance - Trait variance not covered #338

marioortizmanero opened this issue Feb 9, 2022 · 0 comments

Comments

@marioortizmanero
Copy link

marioortizmanero commented Feb 9, 2022

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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant