@@ -13,7 +13,7 @@ fn speed(start: u32, end: u32, time_elapsed: u32) -> u32 {
|
||||
If you have a keen eye, you might have spotted one issue[^one]: what happens if `time_elapsed` is zero?
|
||||
|
||||
You can try it
|
||||
out [on the Rust playground](https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=36e5ddbe3b3f741dfa9f74c956622bac)!
|
||||
out [on the Rust playground](https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=36e5ddbe3b3f741dfa9f74c956622bac)!\
|
||||
The program will exit with the following error message:
|
||||
|
||||
```text
|
||||
@@ -21,7 +21,7 @@ thread 'main' panicked at src/main.rs:3:5:
|
||||
attempt to divide by zero
|
||||
```
|
||||
|
||||
This is known as a **panic**.
|
||||
This is known as a **panic**.\
|
||||
A panic is Rust's way to signal that something went so wrong that
|
||||
the program can't continue executing, it's an **unrecoverable error**[^catching]. Division by zero classifies as such an
|
||||
error.
|
||||
|
||||
Reference in New Issue
Block a user