enums3 feedback

Open
#2,127 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
30/100
Issue type
Feature
Clarity
Mostly clear
Activity status
Stale
Tech stack
rust
Domain
content

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.

Description

A-exercises C-enhancement

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.

Dominant language
Rust
Stars
64.6k
Forks
11.3k
PR merge metrics
No merged PRs in 30d

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from rust-lang/rustlings

All issues in rust-lang/rustlings

Similar issues

More Rust issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.