面试题答案
一键面试fn square_if_greater_than_10(num: i32) -> Option<i32> {
if num > 10 {
Some(num * num)
} else {
None
}
}
fn main() {
let result = square_if_greater_than_10(15);
match result {
Some(squared) => println!("The square of the number is: {}", squared),
None => println!("The number is not greater than 10"),
}
}