done with basic calc

This commit is contained in:
2025-02-20 09:59:05 +05:30
parent 57475122a9
commit 7910a25928
9 changed files with 49 additions and 14 deletions

View File

@@ -2,7 +2,9 @@
/// calculate the average speed of the journey.
fn speed(start: u32, end: u32, time_elapsed: u32) -> u32 {
// TODO: Panic with a custom message if `time_elapsed` is 0
if time_elapsed == 0 {
panic!("The journey took no time at all. That's impossible!");
}
(end - start) / time_elapsed
}