diff options
| author | Steve Klabnik <steve@steveklabnik.com> | 2015-09-17 17:06:54 -0400 |
|---|---|---|
| committer | Steve Klabnik <steve@steveklabnik.com> | 2015-09-17 17:06:54 -0400 |
| commit | 40c45ac86a07cfba1fede2ed10a4b2d2c276c9ca (patch) | |
| tree | 993f8553fa1519d61f40cdc66f83841186d6d45e | |
| parent | eeca6a430b99cffa74044019129fd946f3fe8f48 (diff) | |
| parent | b69a51164d078b00d97a4aa7d4a91ec3f4f5a074 (diff) | |
| download | rust-40c45ac86a07cfba1fede2ed10a4b2d2c276c9ca.tar.gz rust-40c45ac86a07cfba1fede2ed10a4b2d2c276c9ca.zip | |
Rollup merge of #28422 - christopherdumas:label_code, r=steveklabnik
| -rw-r--r-- | src/doc/trpl/error-handling.md | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/src/doc/trpl/error-handling.md b/src/doc/trpl/error-handling.md index e335d59b192..230eb0a85ab 100644 --- a/src/doc/trpl/error-handling.md +++ b/src/doc/trpl/error-handling.md @@ -87,7 +87,9 @@ 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 an integer as an argument, doubles it and prints it. +<a name="code-unwrap-double"/> ```rust,should_panic + use std::env; fn main() { @@ -120,7 +122,7 @@ It would be better if we just showed the code for unwrapping because it is so simple, but to do that, we will first need to explore the `Option` and `Result` types. Both of these types have a method called `unwrap` defined on them. -## The `Option` type +### The `Option` type The `Option` type is [defined in the standard library][5]: @@ -137,6 +139,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 to find a character in a string: +<a name="code-option-ex-string-find"/> ```rust // Searches `haystack` for the Unicode character `needle`. If one is found, the // byte offset of the character is returned. Otherwise, `None` is returned. |
