@@ -87,7 +87,7 @@ thread '<main>' panicked at 'Invalid number: 11', src/bin/panic-simple.rs:5
87
87
Here's another example that is slightly less contrived. A program that accepts
88
88
an integer as an argument, doubles it and prints it.
89
89
90
- <a name =" code-unwrap-double " / >
90
+ <div id =" code-unwrap-double " >
91
91
``` rust,should_panic
92
92
93
93
use std::env;
@@ -99,6 +99,7 @@ fn main() {
99
99
println!("{}", 2 * n);
100
100
}
101
101
```
102
+ </div >
102
103
103
104
If you give this program zero arguments (error 1) or if the first argument
104
105
isn't an integer (error 2), the program will panic just like in the first
@@ -139,7 +140,7 @@ system is an important concept because it will cause the compiler to force the
139
140
programmer to handle that absence. Let's take a look at an example that tries
140
141
to find a character in a string:
141
142
142
- <a name =" code-option-ex-string-find " / >
143
+ <div id =" code-option-ex-string-find " >
143
144
``` rust
144
145
// Searches `haystack` for the Unicode character `needle`. If one is found, the
145
146
// byte offset of the character is returned. Otherwise, `None` is returned.
@@ -152,6 +153,7 @@ fn find(haystack: &str, needle: char) -> Option<usize> {
152
153
None
153
154
}
154
155
```
156
+ </div >
155
157
156
158
Notice that when this function finds a matching character, it doen't just
157
159
return the ` offset ` . Instead, it returns ` Some(offset) ` . ` Some ` is a variant or
0 commit comments