solution to exercise 02_04

This commit is contained in:
David Doblas Jiménez 2024-06-13 17:04:21 +02:00
parent 211f23cea4
commit f91cc0089a

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
}