📜  rust BMI - Rust 代码示例

📅  最后修改于: 2022-03-11 14:49:25.693000             🧑  作者: Mango

代码示例1
fn bmi(weight: u32, height: f32) -> &'static str {
    let index = weight as f32 / height.powi(2);
    match index {
        index if index <= 18.5 => "Underweight",
        index if index <= 25.0 => "Normal",
        index if index <= 30.0 => "Overweight",
        _ => "Obese"
    }
}