Guest User

Untitled

a guest
Jun 19th, 2018
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.33 KB | None | 0 0
  1. fn bmi(weight: u32, height: f32) -> &'static str {
  2. let bmi: f64 = (weight as f64) / (height as f64).powf(2.0);
  3. match bmi {
  4. x if x <= 18.5 => "Underweight",
  5. x if x <= 25.0 => "Normal",
  6. x if x <= 30.0 => "Overweight",
  7. _ => "Obese",
  8. }
  9. }
  10.  
  11. #[test]
  12. fn basic_unit_test() {
  13. assert_eq!(bmi(80, 1.80), "Normal");
  14. }
Add Comment
Please, Sign In to add comment