rust-lang / rust-lang/rustlings
enums3 feedback
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 64.2k
- Forks
- 11.3k
- Avg merge
- 5h 24m
- Merged PRs (30d)
- 2
Description
You can "cheese" enums3 by putting the test's desired values in the match statements:
match message {
Message::Resize { width, height } => self.resize(10, 30),
Message::ChangeColor(red, green, blue) => self.change_color(255, 0, 255),
Message::Quit => self.quit(),
Message::Move(Point) => self.move_position(Point),
Message::Echo(String) => self.echo(String),
}
This passes the test, albeit with a bunch of warnings about how the variables are unused.
Maybe add a second pass test to make sure the values are being passed through from state.process()?
I also found that I had absolutely no idea why I would be using "r, g, b" over "red, green, blue" when these are not technically defined by me. Is this some function of structs/enums? Is it part of a standard library? Is it specific to rgb?
Also, maybe this exercise should take further advantage of match patterns? If the exercise's purpose is to teach match pattern syntax, I think maybe it should show off exhaustive match patterns as well. (Or maybe there should just be an entire exercise folder dedicated to match patterns, because this throws several new concepts at you at once.)
Hopefully I am not wasting time with this issue, I just found this exercise really confusing.
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 enums3 exercise and its existing test, especially the state.process() path mentioned in the report. Check how the match statements currently teach pattern matching, then determine the exercise and test changes needed to verify values are passed through and to clarify the naming and pattern-syntax guidance.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- content
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 30/100