@@ -21,35 +21,35 @@ sum types and combinators, and try to motivate the way Rust does error handling
2121incrementally. As such, programmers with experience in other expressive type
2222systems may want to jump around.
2323
24- * [ The Basics] ( #The%20Basics )
25- * [ Unwrapping explained] ( #Unwrapping%20explained )
26- * [ The ` Option ` type] ( #The%20Option%20type )
27- * [ Composing ` Option<T> ` values] ( #Composing%20Option%3CT%3E%20values )
28- * [ The ` Result ` type] ( #The%20Result%20type )
29- * [ Parsing integers] ( #Parsing%20integers )
30- * [ The ` Result ` type alias idiom] ( #The%20Result%20type%20alias%20idiom )
31- * [ A brief interlude: unwrapping isn't evil] ( #A%20brief%20interlude:%20unwrapping%20isnt%20evil )
32- * [ Working with multiple error types] ( #Working%20with%20multiple%20error%20types )
33- * [ Composing ` Option ` and ` Result ` ] ( #Composing%20Option%20and%20Result )
34- * [ The limits of combinators] ( #The%20limits%20of%20combinators )
35- * [ Early returns] ( #Early%20returns )
36- * [ The ` try! ` macro] ( #The%20try%20macro )
37- * [ Defining your own error type] ( #Defining%20your%20own%20error%20type )
38- * [ Standard library traits used for error handling] ( #Standard%20library%20traits%20used%20for%20error%20handling )
39- * [ The ` Error ` trait] ( #The%20Error%20trait )
40- * [ The ` From ` trait] ( #The%20From%20trait )
41- * [ The real ` try! ` macro] ( #The%20real%20try%20macro )
42- * [ Composing custom error types] ( #Composing%20custom%20error%20types )
43- * [ Advice for library writers] ( #Advice%20for%20library%20writers )
44- * [ Case study: A program to read population data] ( #Case%20study:%20A%20program%20to%20read%20population%20data )
45- * [ Initial setup] ( #Initial%20setup )
46- * [ Argument parsing] ( #Argument%20parsing )
47- * [ Writing the logic] ( #Writing%20the%20logic )
48- * [ Error handling with ` Box<Error> ` ] ( #Error%20handling%20with%20Box%3CError%3E )
49- * [ Reading from stdin] ( #Reading%20from%20stdin )
50- * [ Error handling with a custom type] ( #Error%20handling%20with%20a%20custom%20type )
51- * [ Adding functionality] ( #Adding%20functionality )
52- * [ The short story] ( #The%20short%20story )
24+ * [ The Basics] ( #the-basics )
25+ * [ Unwrapping explained] ( #unwrapping-explained )
26+ * [ The ` Option ` type] ( #the-option-type )
27+ * [ Composing ` Option<T> ` values] ( #composing-optiont-values )
28+ * [ The ` Result ` type] ( #the-result-type )
29+ * [ Parsing integers] ( #parsing-integers )
30+ * [ The ` Result ` type alias idiom] ( #the-result-type-alias-idiom )
31+ * [ A brief interlude: unwrapping isn't evil] ( #a-brief-interlude-unwrapping-isnt-evil )
32+ * [ Working with multiple error types] ( #working-with-multiple-error-types )
33+ * [ Composing ` Option ` and ` Result ` ] ( #composing-option-and-result )
34+ * [ The limits of combinators] ( #the-limits-of-combinators )
35+ * [ Early returns] ( #early-returns )
36+ * [ The ` try! ` macro] ( #the-try-macro )
37+ * [ Defining your own error type] ( #defining-your-own-error-type )
38+ * [ Standard library traits used for error handling] ( #standard-library-traits-used-for-error-handling )
39+ * [ The ` Error ` trait] ( #the-error-trait )
40+ * [ The ` From ` trait] ( #the-from-trait )
41+ * [ The real ` try! ` macro] ( #the-real-try-macro )
42+ * [ Composing custom error types] ( #composing-custom-error-types )
43+ * [ Advice for library writers] ( #advice-for-library-writers )
44+ * [ Case study: A program to read population data] ( #case-study-a-program-to-read-population-data )
45+ * [ Initial setup] ( #initial-setup )
46+ * [ Argument parsing] ( #argument-parsing )
47+ * [ Writing the logic] ( #writing-the-logic )
48+ * [ Error handling with ` Box<Error> ` ] ( #error-handling-with-boxerror )
49+ * [ Reading from stdin] ( #reading-from-stdin )
50+ * [ Error handling with a custom type] ( #error-handling-with-a-custom-type )
51+ * [ Adding functionality] ( #adding-functionality )
52+ * [ The short story] ( #the-short-story )
5353
5454# The Basics
5555
@@ -796,7 +796,7 @@ because of the return types of
796796[ ` std::fs::File::open ` ] ( ../std/fs/struct.File.html#method.open ) and
797797[ ` std::io::Read::read_to_string ` ] ( ../std/io/trait.Read.html#method.read_to_string ) .
798798(Note that they both use the [ ` Result ` type alias
799- idiom] ( #The%20Result%20type%20alias%20idiom ) described previously. If you
799+ idiom] ( #the-result-type-alias-idiom ) described previously. If you
800800click on the ` Result ` type, you'll [ see the type
801801alias] ( ../std/io/type.Result.html ) , and consequently, the underlying
802802` io::Error ` type.) The third problem is described by the
@@ -1120,7 +1120,7 @@ returns an `&Error`, which is itself a trait object. We'll revisit the
11201120
11211121For now, it suffices to show an example implementing the ` Error ` trait. Let's
11221122use the error type we defined in the
1123- [ previous section] ( #Defining%20your%20own%20error%20type ) :
1123+ [ previous section] ( #defining-your-own-error-type ) :
11241124
11251125``` rust
11261126use std :: io;
@@ -1493,19 +1493,19 @@ representation. But certainly, this will vary depending on use cases.
14931493At a minimum, you should probably implement the
14941494[ ` Error ` ] ( ../std/error/trait.Error.html )
14951495trait. This will give users of your library some minimum flexibility for
1496- [ composing errors] ( #The%20real%20try%20macro ) . Implementing the ` Error ` trait also
1496+ [ composing errors] ( #the-real-try-macro ) . Implementing the ` Error ` trait also
14971497means that users are guaranteed the ability to obtain a string representation
14981498of an error (because it requires impls for both ` fmt::Debug ` and
14991499` fmt::Display ` ).
15001500
15011501Beyond that, it can also be useful to provide implementations of ` From ` on your
15021502error types. This allows you (the library author) and your users to
1503- [ compose more detailed errors] ( #Composing%20custom%20error%20types ) . For example,
1503+ [ compose more detailed errors] ( #composing-custom-error-types ) . For example,
15041504[ ` csv::Error ` ] ( http://burntsushi.net/rustdoc/csv/enum.Error.html )
15051505provides ` From ` impls for both ` io::Error ` and ` byteorder::Error ` .
15061506
15071507Finally, depending on your tastes, you may also want to define a
1508- [ ` Result ` type alias] ( #The%20Result%20type%20alias%20idiom ) , particularly if your
1508+ [ ` Result ` type alias] ( #the-result-type-alias-idiom ) , particularly if your
15091509library defines a single error type. This is used in the standard library
15101510for [ ` io::Result ` ] ( ../std/io/type.Result.html )
15111511and [ ` fmt::Result ` ] ( ../std/fmt/type.Result.html ) .
@@ -1538,7 +1538,7 @@ and [`rustc-serialize`](https://crates.io/crates/rustc-serialize) crates.
15381538
15391539We're not going to spend a lot of time on setting up a project with
15401540Cargo because it is already covered well in [ the Cargo
1541- section] ( getting-started.html#Hello%20Cargo ) and [ Cargo's documentation] [ 14 ] .
1541+ section] ( getting-started.html#hello-cargo ) and [ Cargo's documentation] [ 14 ] .
15421542
15431543To get started from scratch, run ` cargo new --bin city-pop ` and make sure your
15441544` Cargo.toml ` looks something like this:
@@ -1729,7 +1729,7 @@ error types and you don't need any `From` implementations. The downside is that
17291729since ` Box<Error> ` is a trait object, it * erases the type* , which means the
17301730compiler can no longer reason about its underlying type.
17311731
1732- [ Previously] ( #The%20limits%20of%20combinators ) we started refactoring our code by
1732+ [ Previously] ( #the-limits-of-combinators ) we started refactoring our code by
17331733changing the type of our function from ` T ` to ` Result<T, OurErrorType> ` . In
17341734this case, ` OurErrorType ` is only ` Box<Error> ` . But what's ` T ` ? And can we add
17351735a return type to ` main ` ?
0 commit comments