mirror of
https://github.com/google/comprehensive-rust.git
synced 2024-11-21 13:25:53 +02:00
Point out new code in Luhn exercise solution (#2409)
This makes it easier for the students to understand where the changes and thus fixes are.
This commit is contained in:
parent
0c824ab740
commit
09a072b1ce
@ -57,12 +57,15 @@ pub fn luhn(cc_number: &str) -> bool {
|
||||
}
|
||||
double = !double;
|
||||
} else if c.is_whitespace() {
|
||||
// New: accept whitespace.
|
||||
continue;
|
||||
} else {
|
||||
// New: reject all other characters.
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// New: check that we have at least two digits
|
||||
digits >= 2 && sum % 10 == 0
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user