1
Fork 0

Auto merge of #28492 - Ms2ger:a-name, r=steveklabnik

The id attribute has been an official part of HTML since 1997. There is no
reason not to use it.
This commit is contained in:
bors 2015-09-18 14:06:51 +00:00
commit 53ba768b8a

View file

@ -87,7 +87,7 @@ thread '<main>' panicked at 'Invalid number: 11', src/bin/panic-simple.rs:5
Here's another example that is slightly less contrived. A program that accepts Here's another example that is slightly less contrived. A program that accepts
an integer as an argument, doubles it and prints it. an integer as an argument, doubles it and prints it.
<a name="code-unwrap-double"/> <div id="code-unwrap-double">
```rust,should_panic ```rust,should_panic
use std::env; use std::env;
@ -99,6 +99,7 @@ fn main() {
println!("{}", 2 * n); println!("{}", 2 * n);
} }
``` ```
</div>
If you give this program zero arguments (error 1) or if the first argument If you give this program zero arguments (error 1) or if the first argument
isn't an integer (error 2), the program will panic just like in the first 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
programmer to handle that absence. Let's take a look at an example that tries programmer to handle that absence. Let's take a look at an example that tries
to find a character in a string: to find a character in a string:
<a name="code-option-ex-string-find"/> <div id="code-option-ex-string-find">
```rust ```rust
// Searches `haystack` for the Unicode character `needle`. If one is found, the // Searches `haystack` for the Unicode character `needle`. If one is found, the
// byte offset of the character is returned. Otherwise, `None` is returned. // byte offset of the character is returned. Otherwise, `None` is returned.
@ -152,6 +153,7 @@ fn find(haystack: &str, needle: char) -> Option<usize> {
None None
} }
``` ```
</div>
Notice that when this function finds a matching character, it doen't just Notice that when this function finds a matching character, it doen't just
return the `offset`. Instead, it returns `Some(offset)`. `Some` is a variant or return the `offset`. Instead, it returns `Some(offset)`. `Some` is a variant or