Skip to content

Instantly share code, notes, and snippets.

@luismendes070
Last active March 3, 2024 13:30
Show Gist options
  • Save luismendes070/4d6ba7823124e1f75a1c6c4b57413f36 to your computer and use it in GitHub Desktop.
Save luismendes070/4d6ba7823124e1f75a1c6c4b57413f36 to your computer and use it in GitHub Desktop.
Índice massa corporal #Copilot
IMC Rust #Copilot
@luismendes070
Copy link
Author

In this version, the read_input function returns a Result<f32, &'static str>. If the parsing fails or the number is not greater than zero, it returns an error with a custom error message. The main function then checks the results of read_input separately for weight and height, and prints an appropriate error message if there was an error. This way, the user will know whether the error was with the weight or the height. I hope this helps! Let me know if you have any other questions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment