Mention struct-like variants in enums2 hint instead of anonymous structs#2353
Mention struct-like variants in enums2 hint instead of anonymous structs#2353orzechow wants to merge 2 commits intorust-lang:mainfrom
Conversation
|
See also my PR to improve the Rust docs on that matter: |
|
I think the list of possible variants is still not correct. There are three possibilities, syntactically:
Not sure about the names, but these are the three syntactic possibilities that should be reflected. |
|
Thanks for the feedback! I agree, let's cleanup the list as well.
See f9f8a37 @senekor Shall I also add those code snippets, you suggested? Like this: |
|
Good idea to check the reference for what terms it uses. If the reference uses both, I would lean toward using "unit-like" instead of "unit-only", for uniformity. But both are fine. Reading over that hint again, the expression "variants with different types" also bugs me a little. The three possibilities "struct-like", "tuple-like" and "unit-like" aren't "types" in the context of a programming language... They are rather syntactic elements used to define a type. I took a stab at rewriting the hint. What do you think, is it too much? @orzechow your commits show up as unverified btw., you might want to check your signing config :) |
|
Agree, let's be precise.
Also, after re-reading the reference, an enum is called I'd keep the code example and condense the description to: @senekor What do you think? PS: Thanks for the signing hint – that shouldn't have happened… |
|
I like this version a lot. @mo8it what do you think? |
The current hint of the enums2 exercise uses an outdated term for struct-like enum variants, which is confusing to Rust newbies:
The term
anonymous structseems outdated. It's neither mentioned in the Rust book on structs or enums, nor the references on structs or enums.A web search rather points to a Rust Forum thread hinting
The only place I found this term, is in the Rust docs on enums, but not in the docs on structs.
It seems like Rust used this term once, but not anymore. See also #1204 and the 2018 edition Rust book on enums.
Instead the book on enums now calls it
named fields, like a struct.The reference on enums uses the term
struct-like enum variant.Therefore, I'd suggest updating this hint to
struct-like enum variants.