3 ms·
fn calculate_tax(income: i32) -> i32 { match income { 0..=9 => 0, 10..=49 => 20, _ => 50, } } https://p
by delta1 6y ago
fn calculate_tax(income: i32) -> i32 {
match income {
0..=9 => 0,
10..=49 => 20,
_ => 50,
}
}
https://play.rust-lang.org/?version=stable&mode=debug&edition=2018&gist=64cd9c40d4783dc95dbdb38ae2824c55 https://play.rust-lang.org/?version=stable&mode=debug&editio...
- nyanpasu64 6y agoThis behaves differently for negative incomes, which are not prohibited by the i32 argument passed in (u32 cannot take on negative values).