Skip to content

Replace match expression with match! macro #5034

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
merged 1 commit into from
Oct 19, 2021

Conversation

ytmimi
Copy link
Contributor

@ytmimi ytmimi commented Oct 19, 2021

This is a follow up to 5f4811e

The matches! macro expresses the condition more succinctly and avoids
the extra level of indentation introduced with the match arm body.

src/lists.rs Outdated
@@ -15,6 +15,7 @@ use crate::utils::{
unicode_str_width,
};
use crate::visitor::SnippetProvider;
use DefinitiveListTactic::*;
Copy link
Member

Choose a reason for hiding this comment

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

There's a lot of overlap in variant names with other enums (e.g. ListTactic and SeparatorTactic) so we probably don't want to have a wildcard import globally as subsequent usage makes it hard in some cases to know which is which.

It'd be fine to use this locally within the function/before the matches! call since scoping (and proximity) makes it much more obvious, but if not locally, then I'd prefer to just have the patterns called out explicitly with the full enum variant in the matches! call

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure. When I saw your comment on the previous PR I just assumed you meant to move the use statement to the top of the file, but if it's fine to keep it locally scoped then I'll make that change!

Copy link
Member

Choose a reason for hiding this comment

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

Thanks!

This is a follow up to 5f4811e

The matches! macro expresses the condition more succinctly and avoids
the extra level of indentation introduced with the match arm body.
@ytmimi ytmimi force-pushed the cleanup_issue_4615 branch from 25c2b14 to c35c0db Compare October 19, 2021 02:15
@calebcartwright calebcartwright merged commit 1ae5c35 into rust-lang:master Oct 19, 2021
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