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

Add support for rest pattern #104

Merged
merged 3 commits into from
Jul 31, 2024
Merged

Conversation

GuillaumeGomez
Copy link
Contributor

As discussed in #101, I added support for it.

@GuillaumeGomez
Copy link
Contributor Author

Rebased and fixed clippy. CI is finally happy. :)

if let Target::Rest(s) = target {
if !allow_named_rest && s.inner.is_some() {
return Err(nom::Err::Failure(ErrorContext::new(
format!("`@ ..` cannot be used in {type_kind}"),
Copy link
Collaborator

Choose a reason for hiding this comment

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

Rust uses "@ .. is only allowed in slice patterns". I like that better, because it tells you what you can do, instead of what you can't do.

The code looks fine, so if you like the current phrasing better, then it's not a showstopper for me!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No you're right, I prefer your version. Updating!

@GuillaumeGomez
Copy link
Contributor Author

And done. :)

if let Target::Rest(s) = target {
if !allow_named_rest && s.inner.is_some() {
return Err(nom::Err::Failure(ErrorContext::new(
format!("`@ ..` is only allowed in slice patterns"),
Copy link
Collaborator

Choose a reason for hiding this comment

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

The format!() is not needed anymore.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Even clippy was complaining about it. :3

Copy link
Collaborator

@Kijewski Kijewski left a comment

Choose a reason for hiding this comment

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

Nice! I was afraid of a far bigger diff.

@Kijewski Kijewski merged commit 6d3bec1 into rinja-rs:master Jul 31, 2024
17 checks passed
@GuillaumeGomez GuillaumeGomez deleted the rest-pattern branch July 31, 2024 19:59
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.

2 participants