1
0
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:
Martin Geisler 2024-10-16 11:35:27 +02:00 committed by GitHub
parent 0c824ab740
commit 09a072b1ce
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -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
}