Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

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

Merged
fspoettel merged 17 commits into fspoettel:main from tguichaoua:day
Nov 22, 2023

Conversation

@tguichaoua
Copy link
Contributor

@tguichaoua tguichaoua commented Nov 22, 2023
edited
Loading

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
image

Compile time checked value
image

@tguichaoua tguichaoua marked this pull request as draft November 22, 2023 10:01
@fspoettel fspoettel self-requested a review November 22, 2023 10:17
Copy link
Owner

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! 🙂

@tguichaoua tguichaoua marked this pull request as ready for review November 22, 2023 10:38
Copy link
Contributor Author

tguichaoua commented Nov 22, 2023
edited
Loading

@fspoettel
it should be ready now 😉

Copy link
Owner

@fspoettel fspoettel left a 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.

advent_of_code::main!(DAY_NUMBER);
#[cfg(test)]
mod tests {
Copy link
Owner

@fspoettel fspoettel Nov 22, 2023

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.

Copy link
Contributor Author

@tguichaoua tguichaoua Nov 22, 2023
edited
Loading

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.

https://github.com/tguichaoua/advent-of-code-rust/blob/94c5a487cc59501bc60261d36a9ddd7e2567ff83/src/template/mod.rs#L26-L27

Copy link
Owner

@fspoettel fspoettel Nov 22, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Gotcha, missed that.

tguichaoua and others added 6 commits November 22, 2023 12:54
Co-authored-by: Felix Spöttel <1682504+fspoettel@users.noreply.github.com>
Co-authored-by: Felix Spöttel <1682504+fspoettel@users.noreply.github.com>
Co-authored-by: Felix Spöttel <1682504+fspoettel@users.noreply.github.com>
Co-authored-by: Felix Spöttel <1682504+fspoettel@users.noreply.github.com>
@fspoettel fspoettel merged commit 6d9bf34 into fspoettel:main Nov 22, 2023
Copy link
Owner

Thank you for the contribution! 🙂

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@fspoettel fspoettel fspoettel approved these changes

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

AltStyle によって変換されたページ (->オリジナル) /