mirror of
https://github.com/google/comprehensive-rust.git
synced 2025-06-09 11:06:18 +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;
|
double = !double;
|
||||||
} else if c.is_whitespace() {
|
} else if c.is_whitespace() {
|
||||||
|
// New: accept whitespace.
|
||||||
continue;
|
continue;
|
||||||
} else {
|
} else {
|
||||||
|
// New: reject all other characters.
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// New: check that we have at least two digits
|
||||||
digits >= 2 && sum % 10 == 0
|
digits >= 2 && sum % 10 == 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user