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

Consider how idiomatic numeric type suffixes are #203

Closed
illicitonion opened this issue Oct 31, 2024 · 0 comments · Fixed by #239
Closed

Consider how idiomatic numeric type suffixes are #203

illicitonion opened this issue Oct 31, 2024 · 0 comments · Fixed by #239

Comments

@illicitonion
Copy link
Contributor

The most obvious way to solve https://github.com/mainmatter/100-exercises-to-learn-rust/blob/main/exercises/02_basic_calculator/01_integers/src/lib.rs is to replace the u8 suffix with a u32 suffix. This is also what's present in the solutions branch, and is valid and correct.

But I'd suggest the most idiomatic way of solving this would be to remove the u8 suffix completely and rely on inference. It generally wouldn't occur to me when writing this code to include a suffix.

I'm not sure we need to take any action here, and this may just be a question of personal style, but it came up while I was watching a novice programmer take the course, so I figured I'd raise it for discussion. We may want to add a comment about the two options, or slightly change the exercise to guide in one direction or the other.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant