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

Use match + pattern guard instead of if in visitor #1

Closed
WaffleLapkin opened this issue Oct 14, 2019 · 0 comments
Closed

Use match + pattern guard instead of if in visitor #1

WaffleLapkin opened this issue Oct 14, 2019 · 0 comments
Assignees
Labels

Comments

@WaffleLapkin
Copy link
Contributor

I propose to change visitor.rs#L40-L45 to

match entry {
    (tag, value) if tag == self.tag => Ok(value),
    _ => Err(A::Error::custom(format!(r#"key "{tag}""#, tag = self.tag))),
}

as rust 1.39 hits stable (rustc 1.38 fails to compile this code, see bind_by_move_pattern_guards). In my opinion, this provides more readable code.

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

No branches or pull requests

1 participant