File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -39,7 +39,12 @@ fn main() {
3939```
4040
4141We attempt to access the hundredth element of our vector, but it only has three
42- elements. In this situation, Rust will panic. Let' s try it:
42+ elements. In this situation, Rust will panic. Using `[]` is supposed to return
43+ a number. But if you pass it an invalid index, there' s no number Rust could
44+ return here, it would be wrong. So the only thing that we can do is terminate
45+ the program.
46+
47+ Let' s try to run it:
4348
4449```bash
4550$ cargo run
@@ -97,8 +102,3 @@ error: Process didn't exit successfully: `target/debug/panic` (exit code: 101)
97102
98103That' s a lot of output! Line ` 11` there has the line in our project:
99104` src/main.rs` line four.
100-
101- So why does Rust panic here? In this case, using `[]` is supposed to return
102- a number. But if you pass it an invalid index, there' s no number Rust could
103- return here, it would be wrong. So the only thing that we can do is terminate
104- the program.
You can’t perform that action at this time.
0 commit comments