Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- fn bmi(weight: u32, height: f32) -> &'static str {
- let bmi: f64 = (weight as f64) / (height as f64).powf(2.0);
- match bmi {
- x if x <= 18.5 => "Underweight",
- x if x <= 25.0 => "Normal",
- x if x <= 30.0 => "Overweight",
- _ => "Obese",
- }
- }
- #[test]
- fn basic_unit_test() {
- assert_eq!(bmi(80, 1.80), "Normal");
- }
Add Comment
Please, Sign In to add comment