Skip to content

Commit e3774aa

Browse files
committed
robot-name: use is_ascii_* functions
https://rust-lang.github.io/rust-clippy/master/index.html#manual_is_ascii_check Using the built-in functions is more readable and makes it clear that it’s not a specific subset of characters, but all ASCII (lowercase|uppercase|digit) characters.
1 parent aa6b295 commit e3774aa

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

exercises/practice/robot-name/tests/robot-name.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@ use robot_name as robot;
33
fn assert_name_matches_pattern(n: &str) {
44
assert!(n.len() == 5, "name is exactly 5 characters long");
55
assert!(
6-
n[0..2].chars().all(|c| ('A'..='Z').contains(&c)),
6+
n[0..2].chars().all(|c| c.is_ascii_uppercase()),
77
"name starts with 2 uppercase letters"
88
);
99
assert!(
10-
n[2..].chars().all(|c| ('0'..='9').contains(&c)),
10+
n[2..].chars().all(|c| c.is_ascii_digit()),
1111
"name ends with 3 numbers"
1212
);
1313
}

0 commit comments

Comments
 (0)