Skip to content

Commit 796e183

Browse files
committed
Use matches! macro and rename sanitize function
1 parent fb0c5f2 commit 796e183

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)