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

enums3 feedback #2127

Open
twoda5h opened this issue Oct 7, 2024 · 3 comments
Open

enums3 feedback #2127

twoda5h opened this issue Oct 7, 2024 · 3 comments
Labels
A-exercises Area: Exercises C-enhancement Category: Enhancement

Comments

@twoda5h
Copy link

twoda5h commented Oct 7, 2024

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.

@mo8it
Copy link
Contributor

mo8it commented Oct 9, 2024

Rustlings avoids trying to prevent users from cheesing exercises. It is not a test, it is something people use to learn on their own.
We try to prevent passing by mistake, but not cheesing on purpose.

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?

I improved the choice of variable names in the solution in f516da4. But I am not sure that I correctly understood what you mean here. Could you please elaborate?

Also, maybe this exercise should take further advantage of match patterns?

Teaching about nested pattern matching in a new exercise is a good idea. Could you please open a new issue for this? :)

@twoda5h
Copy link
Author

twoda5h commented Oct 9, 2024

We try to prevent passing by mistake, but not cheesing on purpose.

i actually didn't cheese it on purpose, it was a mistake and i only found out because i checked the solution myself afterwards, i thought i just needed to make it match what the tests wanted. may be a quirk with how i learn (or avoid learning at all) myself

I improved the choice of variable names in the solution in f516da4. But I am not sure that I correctly understood what you mean here. Could you please elaborate?

-> typing this after looking back over the original code just now: i think i was just having a """"little bit"""" of trouble with reading the rustbook. didn't understand how it was accepting r, g, b when they weren't used earlier in the code and i can easily see now that it was using those as u8, u8, u8.

@mo8it
Copy link
Contributor

mo8it commented Nov 11, 2024

i actually didn't cheese it on purpose, it was a mistake

Then we should improve the tests. You are welcome to open a PR :D

@mo8it mo8it added C-enhancement Category: Enhancement A-exercises Area: Exercises labels Nov 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-exercises Area: Exercises C-enhancement Category: Enhancement
Projects
None yet
Development

No branches or pull requests

2 participants