Rewrite a variety of .contains() calls as matches! statements (#5432)

## Summary

These have the potential to be much more efficient, as we've seen in the
past.
This commit is contained in:
Charlie Marsh 2023-06-28 22:42:27 -04:00 committed by GitHub
parent aa887d5a1d
commit a973019358
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
10 changed files with 183 additions and 169 deletions

View file

@ -1,13 +1,17 @@
/// A copy of `__future__.all_feature_names`.
pub const ALL_FEATURE_NAMES: &[&str] = &[
"nested_scopes",
"generators",
"division",
"absolute_import",
"with_statement",
"print_function",
"unicode_literals",
"barry_as_FLUFL",
"generator_stop",
"annotations",
];
/// Returns `true` if `name` is a valid `__future__` feature name, as defined by
/// `__future__.all_feature_names`.
pub fn is_feature_name(name: &str) -> bool {
matches!(
name,
"nested_scopes"
| "generators"
| "division"
| "absolute_import"
| "with_statement"
| "print_function"
| "unicode_literals"
| "barry_as_FLUFL"
| "generator_stop"
| "annotations"
)
}