Skip to content

Commit 88fba22

Browse files
committed
Auto merge of #2645 - JohnTitor:matches, r=jtgeibel
Use `matches!` macro and rename sanitize function Use matches macro which is stabilized in 1.42.0. And rename it from `whitelist` to `is_allowed_char` since it's ambiguous to return true when an unexpected character comes in, even though it's "whitelist". r? @jtgeibel just in case but feel free to r=anyone as it's a quite simple change.
2 parents a110ec0 + 796e183 commit 88fba22

File tree

1 file changed

+3
-6
lines changed

1 file changed

+3
-6
lines changed

src/models/team.rs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -123,14 +123,11 @@ impl Team {
123123
// check that `team` is the `slug` in results, and grab its data
124124

125125
// "sanitization"
126-
fn whitelist(c: char) -> bool {
127-
match c {
128-
'a'..='z' | 'A'..='Z' | '0'..='9' | '-' | '_' => false,
129-
_ => true,
130-
}
126+
fn is_allowed_char(c: char) -> bool {
127+
matches!(c, 'a'..='z' | 'A'..='Z' | '0'..='9' | '-' | '_')
131128
}
132129

133-
if let Some(c) = org_name.chars().find(|c| whitelist(*c)) {
130+
if let Some(c) = org_name.chars().find(|c| !is_allowed_char(*c)) {
134131
return Err(cargo_err(&format_args!(
135132
"organization cannot contain special \
136133
characters like {}",

0 commit comments

Comments
 (0)