Skip to content

Commit 9ad579f

Browse files
authored
phone-number, scale-generator: use range::contains (#1036)
I'm honestly not really convinced by the phone-number one but I guess it's one fewer mention of number_len so it's fine. https://rust-lang.github.io/rust-clippy/master/index.html#manual_range_contains
1 parent 0b3a64e commit 9ad579f

File tree

2 files changed

+2
-3
lines changed

2 files changed

+2
-3
lines changed

exercises/phone-number/example.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,7 @@ pub fn number(user_number: &str) -> Option<String> {
33

44
let number_len = filtered_number.len();
55

6-
if number_len < 10
7-
|| number_len > 11
6+
if !(10..=11).contains(&number_len)
87
|| (filtered_number.len() == 11 && !filtered_number.starts_with('1'))
98
{
109
return None;

exercises/scale-generator/example.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,7 @@ pub mod note {
244244
let mut iter = lc.chars();
245245

246246
let mut note = match iter.next() {
247-
Some(c) if 'a' <= c && 'g' >= c => Note {
247+
Some(c) if ('a'..='g').contains(&c) => Note {
248248
tonic: match c {
249249
'a' => Root::A,
250250
'b' => Root::B,

0 commit comments

Comments
 (0)