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

Macros #15

Merged
merged 2 commits into from
Aug 3, 2024
Merged

Macros #15

merged 2 commits into from
Aug 3, 2024

Conversation

adnilsson
Copy link
Owner

@adnilsson adnilsson commented Jul 23, 2024

Description

Solution to the Macros exercise.

Mentoring

First iteration

By referencing the excellent Programming Rust book, I could see how to do repeated matching and unrolling, as well as a neat extra case to deal with optional trailing commas. My only question for the mentor was if this is still how one would typically "solve" optional trailing commas for macros that do repeated matching. However, this time, the mentor did not provide any constructive feedback. Unfortunately, they admitted to not having the best understanding of Rust's declarative macros. It took quite some time for any mentor to take up my assignment, so I did not re-submit for additional mentoring. I also think this solution is good, so let's keep swimming.

Abbreviated review comments from the mentor on 3de0415:

That said, if it's working, why change it? This is pretty much all Greek to begin with. I think your solution is wonderful. :)

Uses an extra pattern to capture trailing commas.
The `$crate` fragment is used to refer to the crate that defines the
macro.
An absolute path is used to refer to std to avoid local shadowing.
@adnilsson adnilsson merged commit f6155ed into main Aug 3, 2024
@adnilsson adnilsson deleted the macros branch August 3, 2024 16:21
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 this pull request may close these issues.

1 participant