I have a number in Option. I need to replace it with max value of it and some other value, or use that other value if my number is None.
I wrote a function to do so:
fn max(a: Option<u32>, b: u32) -> Option<u32> {
if a.is_some() {
Some(std::cmp::max(a.unwrap(), b))
} else {
Some(b)
}
}
But I can't stop thinking there is a better and concise way to do so using methods of Option. Can you help me?