Rust's `match` is liberatingPosted on 2023-02-15🏷: rust || 1 minute readTable of ContentsHave you met foo before?I bet you have!Solve problems without interruptionHave you met foo before?fn foo(n: usize, k: usize) -> usize { match (n, k) { (_, 0) => 1, (0, _) => 0, _ => foo(n-1, k-1) + foo(n-1, k) } } I bet you have!fn bar(x: f64, k: i32) -> f64 { use std::cmp::Ordering::*; /* types don't exist at runtime */ match k.cmp(&0) { Less => 0., Equal => 1., Greater => (0..k) .map(|i| (x - i as f64) / (k - i) as f64 ).product() } } Solve problems without interruptionHave fun on the playground.