File tree 1 file changed +6
-6
lines changed
1 file changed +6
-6
lines changed Original file line number Diff line number Diff line change @@ -39,7 +39,12 @@ fn main() {
39
39
```
40
40
41
41
We 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:
43
48
44
49
```bash
45
50
$ cargo run
@@ -97,8 +102,3 @@ error: Process didn't exit successfully: `target/debug/panic` (exit code: 101)
97
102
98
103
That' s a lot of output! Line ` 11` there has the line in our project:
99
104
` 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