perfect-numbers: extract Some
(need to make any arbitrary change so that this exercise is tested in PR)
@@ -3,11 +3,11 @@ pub fn classify(num: u64) -> Option<Classification> {
return None;
}
let sum: u64 = (1..num).filter(|i| num % i == 0).sum();
- match sum.cmp(&num) {
- std::cmp::Ordering::Equal => Some(Classification::Perfect),
- std::cmp::Ordering::Less => Some(Classification::Deficient),
- std::cmp::Ordering::Greater => Some(Classification::Abundant),
- }
+ Some(match sum.cmp(&num) {
+ std::cmp::Ordering::Equal => Classification::Perfect,
+ std::cmp::Ordering::Less => Classification::Deficient,
+ std::cmp::Ordering::Greater => Classification::Abundant,
+ })
}
#[derive(Debug, PartialEq, Eq)]
