-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Document generic parameter variance in rustdoc #3515
Comments
I wonder if rust-lang/rust's issue tracker would be a better fit. 🤔 There are two questions that immediately pop into my head:
|
what about just using colors (+ hovers for colorblind readers), or other text decoration (e.g. solid/dotted underline)? it doesn't feel right for rustdoc to add its own syntax within something that seems to be Rust syntax. |
As for reporting it in the rust-lang/rust issue tracker, it seems this issue still involves some UI design, so it probably needs to go through the RFC process anyway? I'm not familiar with this field, so I'm just writing down the requirement without digging into the details. Also personally I don't really "need" this feature, I just feel that rustdoc should provide this information in its output to increase developers' awareness that variance is part of the type signature. |
Right, I fully agree. I just listed that for the sake of completeness as seen by all the CONs.
That's another option I haven't considered. Although I can imagine that colors and text decoration are just as distracting as obscure symbols. On top of that, there's been a move to reduce the amount of colors in rustdoc (rust-lang/rust#91480). I actually quite like the idea of hovers … for all readers, except that they probably wouldn't be super discoverable (but that can be an advantage to some degree).
rust-lang/rfcs is probably fine. I just hadn't seen any rustdoc proposals here before you opened one (excl. rustdoc RFCs ofc), people typically open rustdoc feature requests over at rust-lang/rust. Anyway. I've just added this proposal to the agenda of the next rustdoc meeting. |
I think a subscript could work well: struct Foo<+T, -U> Combined with a tooltip with more explanation. |
maybe the superset/subset operators are more memorizable than plus and minus? |
I think displaying variance is a good idea, but I have a few thoughts.
|
For the record,
As of rust-lang/rust#107339, the compiler doesn't flip region variance anymore. See https://github.com/rust-lang/rust/pull/107339/files#diff-47d6383d2f80e4629905cc926b13600a0974819fc349e2b09772a5dab47ee4bf for example |
Oh, ok. Great. |
Kinda linked to rust-lang/rust#22108. |
Closing in favor of rust-lang/rust#22108. Further discussions should happen over there. |
As initially requested in rust-lang/rust#41537, variance is part of the signature of a type parameter, but it is not documented anywhere directly until the user opens the source code to recursively dig into its usages.
The text was updated successfully, but these errors were encountered: