solution to exercise 02_04
This commit is contained in:
parent
211f23cea4
commit
f91cc0089a
@ -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
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user