-
Notifications
You must be signed in to change notification settings - Fork 61
Add a Day type to provide better handling of day value #35
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
Conversation
Hey @tguichaoua, let me know once this is ready and I'll review it. The change looks like a good improvement, happy to merge it once ready. Thank you! 🙂 |
@fspoettel |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good - the only real issue I found are that the tests in the scaffold template do not interpolateDAY_NUMBER
yet, so they don't work.
@@ -12,7 +14,7 @@ pub fn part_two(input: &str) -> Option<u32> { | |||
None | |||
} | |||
|
|||
advent_of_code::main!(DAY); | |||
advent_of_code::main!(DAY_NUMBER); | |||
|
|||
#[cfg(test)] | |||
mod tests { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The unit tests still have references to DAY
which should be DAY_NUMBER
now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
advent_of_code::main!
creates a const value DAY
of type Day
.
The DAY
in unit tests refer to this const.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Gotcha, missed that.
Co-authored-by: Felix Spöttel <[email protected]>
Co-authored-by: Felix Spöttel <[email protected]>
Co-authored-by: Felix Spöttel <[email protected]>
Co-authored-by: Felix Spöttel <[email protected]>
Thank you for the contribution! 🙂 |
Introduce a type
Day
to enforce static validity of the value and provide better error message to the user.Before / after example with an invalid value

Compile time checked value
