Skip to content

Rollup of 8 pull requests #28516

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 102 commits into from
Sep 19, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
102 commits
Select commit Hold shift + click to select a range
5c5cca5
Small syntax and formatting changes
id4ho Sep 6, 2015
7f5ec6c
Disable browser history API on file:/ URLs
badboy Sep 14, 2015
b096403
Ignore PhantomData when checking CoerceUnsized implementations
ebfull Sep 13, 2015
320880e
Fix option link and anchor links.
Sep 15, 2015
b69a511
Added anchors for the code snippets.
Sep 15, 2015
1b3745f
Add a comment that the `Atomic*` are all implicitly `Send`
tbu- Sep 9, 2015
804f024
Simplify sample code for {Option, Result}::iter_mut
aochagavia Sep 16, 2015
1614173
Specialize `PartialOrd` for totally ordered primitive types
ranma42 Sep 15, 2015
d04b8b5
Improve PartialOrd for slices
ranma42 Sep 15, 2015
9a626df
Add test for #24533
apasel422 Sep 16, 2015
bf9254a
Reuse cmp in totally ordered types
ranma42 Sep 16, 2015
369a9dc
Remove boundary checks in slice comparison operators
ranma42 Sep 16, 2015
08b9edf
Remove inline attribute
ranma42 Sep 16, 2015
74dc146
Explain explicit slicing in slice cmp and partial_cmp methods
ranma42 Sep 16, 2015
f5b69b3
Remove incorrect test for #22872
apasel422 Sep 16, 2015
7352722
Emit an error upon failing to create a temp dir instead of panicking
apasel422 Sep 16, 2015
f18c2aa
Auto merge of #28432 - aochagavia:docs2, r=alexcrichton
bors Sep 16, 2015
47d125d
Auto merge of #28436 - ranma42:faster-partialord, r=bluss
bors Sep 16, 2015
dfe88c0
Change OSX version req wording to match Linux.
dagnir Sep 16, 2015
76856e1
Add an early lint pass for lints that operate on the AST
nrc Sep 10, 2015
70c6fb9
Change the unused parens lint to operate on the AST
nrc Sep 10, 2015
d21bfff
Remove hir::ExprParen
nrc Sep 10, 2015
c1084a3
Changes to tests
nrc Sep 11, 2015
a642d85
Change to a multi-trait approach
nrc Sep 14, 2015
ed61a64
rebasing
nrc Sep 15, 2015
69fdc0f
corrected link to Hasher
dinfuehr Sep 17, 2015
61cb1ba
Add compiler option to keep mtwt tables
GSam Sep 10, 2015
151ffa4
Auto merge of #28453 - dinfuehr:patch-4, r=alexcrichton
bors Sep 17, 2015
d16129b
Auto merge of #28349 - nrc:ast-lints, r=manishearth
bors Sep 17, 2015
4fbe514
Fix the span for ! returns
nrc Sep 17, 2015
6c18dd5
Auto merge of #28438 - apasel422:issue-22872, r=alexcrichton
bors Sep 17, 2015
e3be84c
libsyntax: forbid visibility modifiers for enum variants
matklad Sep 16, 2015
f5a99ae
Remove Visibility field from enum variants
nagisa Sep 16, 2015
d3fc6e1
Auto merge of #28454 - GSam:master, r=nrc
bors Sep 17, 2015
7ff85cd
Correct type definition of HANDLE.
vharavy Sep 17, 2015
a9cb51c
Fix test expectations because of #28439
nagisa Sep 17, 2015
89faafc
Auto merge of #28381 - ebfull:aint-fraid-a-no-ghosts-redux, r=me
bors Sep 17, 2015
c9fc4ef
Auto merge of #28455 - nrc:span-bang, r=alexcrichton
bors Sep 17, 2015
6def06c
Don't create adjustments from a type to itself
dotdash Sep 15, 2015
83b5370
Add tests for #23543, #23544
apasel422 Sep 17, 2015
2be0d0a
Auto merge of #28428 - dotdash:same_adjust, r=nikomatsakis
bors Sep 17, 2015
0675dff
rmake: Get all tests passing on MSVC
alexcrichton Aug 26, 2015
519527b
Remove empty test files
apasel422 Sep 17, 2015
8ea2198
Auto merge of #28421 - alexcrichton:msvc-rmake, r=alexcrichton
bors Sep 17, 2015
6d2cb6c
trpl: Fix off-by-one highest memory address
baskerville Sep 17, 2015
24fdaed
Auto merge of #28457 - VHaravy:test-run-pass-x86stdcall2, r=huonw
bors Sep 17, 2015
25cc001
doc: no need to mention the method by name
tshepang Sep 17, 2015
a06812f
Auto merge of #28459 - apasel422:tests, r=alexcrichton
bors Sep 17, 2015
553a2f1
doc: follow idiom in code snippet
tshepang Sep 17, 2015
22fc5f4
reference: mark that up to make it more clear it is a keyword
tshepang Sep 17, 2015
a3305f8
reference: actual keywords feel more appropriate
tshepang Sep 17, 2015
54063e3
Rollup merge of #28276 - jackwilsonv:patch-5, r=Manishearth
steveklabnik Sep 17, 2015
eeca6a4
Rollup merge of #28314 - tbu-:pr_atomics_are_send, r=brson
steveklabnik Sep 17, 2015
40c45ac
Rollup merge of #28422 - christopherdumas:label_code, r=steveklabnik
steveklabnik Sep 17, 2015
ae3c60d
Rollup merge of #28435 - apasel422:issue-24533, r=nikomatsakis
steveklabnik Sep 17, 2015
cc664f1
Rollup merge of #28451 - dagnir:osx-req-wording, r=steveklabnik
steveklabnik Sep 17, 2015
36190ef
Rollup merge of #28466 - baskerville:trpl-heap-highest-addr, r=stevek…
steveklabnik Sep 17, 2015
fcfcee1
Rollup merge of #28470 - tshepang:idiom, r=steveklabnik
steveklabnik Sep 17, 2015
cd5870f
Rollup merge of #28471 - tshepang:markup, r=steveklabnik
steveklabnik Sep 17, 2015
7a5cd3c
Rollup merge of #28473 - tshepang:lowercase, r=steveklabnik
steveklabnik Sep 17, 2015
5faff5d
Rollup merge of #28474 - tshepang:repetition, r=steveklabnik
steveklabnik Sep 17, 2015
cff0411
Auto merge of #28476 - steveklabnik:rollup, r=steveklabnik
bors Sep 17, 2015
5a91ba8
Fix spelling and remove weirdly placed comma.
dagnir Sep 18, 2015
cbc9517
Clarify where let accepts a pattern, spatially
Wallacoloo Sep 18, 2015
66f662f
Fix crash with --save-analysis
nrc Sep 18, 2015
269c59d
Warn on `pub extern crate`.
nrc Sep 18, 2015
da059a4
Add 1.3 release date
Sep 18, 2015
5fa6e85
Implement empty struct with braces (RFC 218)
petrochenkov Sep 10, 2015
605a472
Add some more tests
petrochenkov Sep 11, 2015
1eb42f1
Add feature gate
petrochenkov Sep 18, 2015
2c17bfc
Skip no-op adjustments in trans
dotdash Sep 18, 2015
1a3b422
Use divs with ids rather than as with names.
Ms2ger Sep 18, 2015
53ba768
Auto merge of #28492 - Ms2ger:a-name, r=steveklabnik
bors Sep 18, 2015
913fe6d
add support for non-standard name of stdc++ library
semarie Sep 18, 2015
dc1c797
Auto merge of #28336 - petrochenkov:empstr, r=pnkfelix
bors Sep 18, 2015
5104a93
Revert "Convert negate_unsigned feature gate to a warning"
nagisa Sep 17, 2015
72a10fa
Auto merge of #28442 - nagisa:remove-enum-vis-field, r=alexcrichton
bors Sep 18, 2015
fb5de8c
Auto merge of #28465 - apasel422:tidy, r=alexcrichton
bors Sep 18, 2015
9d3deb4
fix anchor link
davidszotten Sep 18, 2015
634ffe5
remove preceeding blank line
davidszotten Sep 18, 2015
6e5a325
Auto merge of #28484 - nrc:fix-save, r=alexcrichton
bors Sep 19, 2015
2915f89
Auto merge of #28468 - nagisa:revert-negate-unsigned-warning, r=alexc…
bors Sep 19, 2015
d97be7b
Auto merge of #28486 - nrc:pub-extern-crate, r=alexcrichton
bors Sep 19, 2015
791cc16
Auto merge of #28489 - kud1ing:patch-1, r=alexcrichton
bors Sep 19, 2015
49b1902
added panic docs for print\! and println\! macros
llogiq Sep 19, 2015
b3afb16
Auto merge of #28491 - dotdash:noadjust, r=nikomatsakis
bors Sep 19, 2015
4e42fcd
link needs puncuation
davidszotten Sep 19, 2015
30c91cd
angle brackets get mis-parsed. bug?
davidszotten Sep 19, 2015
3a5e9a3
wrap more referenced code blocks in divs
davidszotten Sep 19, 2015
436e8d6
its vs it's
davidszotten Sep 19, 2015
f7d8b41
missing punctuation
davidszotten Sep 19, 2015
5ab3058
change back to anchors; divs break md
davidszotten Sep 19, 2015
a2fbf9d
Fixed an apparent typo
alex Sep 19, 2015
655b2ef
Auto merge of #28495 - semarie:stdcpp-name, r=alexcrichton
bors Sep 19, 2015
6872d13
Rollup merge of #28400 - badboy:disable-browser-history-on-file, r=st…
steveklabnik Sep 19, 2015
d407903
Rollup merge of #28430 - apasel422:issue-14698, r=alexcrichton
steveklabnik Sep 19, 2015
f1473b6
Rollup merge of #28443 - GuillaumeGomez:error_codes, r=Manishearth
steveklabnik Sep 19, 2015
00d64d6
Rollup merge of #28483 - dagnir:compiler-test-doc-cleanup, r=alexcric…
steveklabnik Sep 19, 2015
d557f4a
Rollup merge of #28485 - Wallacoloo:clarify-let-lhs, r=alexcrichton
steveklabnik Sep 19, 2015
b2c7e77
Rollup merge of #28496 - davidszotten:fix_error_anchors, r=steveklabnik
steveklabnik Sep 19, 2015
0622cf3
Rollup merge of #28511 - llogiq:printdoc, r=steveklabnik
steveklabnik Sep 19, 2015
234f81c
Rollup merge of #28515 - alex:patch-1, r=steveklabnik
steveklabnik Sep 19, 2015
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions COMPILER_TESTS.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Compiler Test Documentation

In the Rust project, we use a special set of comands imbedded in
In the Rust project, we use a special set of comands embedded in
comments to test the Rust compiler. There are two groups of commands:

1. Header commands
Expand Down Expand Up @@ -29,11 +29,11 @@ The error levels that you can have are:
3. `NOTE`
4. `HELP` and `SUGGESTION`*

\* **Note**: `SUGGESTION` must follow emediatly after `HELP`.
\* **Note**: `SUGGESTION` must follow immediately after `HELP`.

## Summary of Header Commands

Header commands specify something about the entire test file, as a
Header commands specify something about the entire test file as a
whole, instead of just a few lines inside the test.

* `ignore-X` where `X` is an architecture, OS or stage will ignore the test accordingly
Expand Down
2 changes: 1 addition & 1 deletion Makefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
#
# * check - Run the complete test suite
#
# * clean - Clean the build repertory. It is advised to run this
# * clean - Clean the build repository. It is advised to run this
# command if you want to build Rust again, after an update
# of the git repository.
#
Expand Down
4 changes: 2 additions & 2 deletions RELEASES.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Version 1.3.0 (September 2015)
Version 1.3.0 (2015-09-17)
==============================

* ~900 changes, numerous bugfixes
Expand Down Expand Up @@ -142,7 +142,7 @@ Misc
[`Error`]: http://doc.rust-lang.org/nightly/std/error/trait.Error.html
[`File`]: http://doc.rust-lang.org/nightly/std/fs/struct.File.html
[`Hash`]: http://doc.rust-lang.org/nightly/std/hash/trait.Hash.html
[`Hasher`]: http://doc.rust-lang.org/nightly/std/hash/trait.Hash.html
[`Hasher`]: http://doc.rust-lang.org/nightly/std/hash/trait.Hasher.html
[`Send`]: http://doc.rust-lang.org/nightly/std/marker/trait.Send.html
[`SliceConcatExt`]: http://doc.rust-lang.org/nightly/std/slice/trait.SliceConcatExt.html
[`Stdin`]: http://doc.rust-lang.org/nightly/std/io/struct.Stdin.html
Expand Down
6 changes: 6 additions & 0 deletions configure
Original file line number Diff line number Diff line change
Expand Up @@ -1095,6 +1095,12 @@ envopt CPP
envopt CFLAGS
envopt CXXFLAGS

# stdc++ name in use
# used to manage non-standard name (on OpenBSD for example)
program_transform_name=$($CFG_CC -v 2>&1 | sed -n "s/.*--program-transform-name='\([^']*\)'.*/\1/p")
CFG_STDCPP_NAME=$(echo "stdc++" | sed "${program_transform_name}")
putvar CFG_STDCPP_NAME

# a little post-processing of various config values
CFG_PREFIX=${CFG_PREFIX%/}
CFG_MANDIR=${CFG_MANDIR%/}
Expand Down
4 changes: 2 additions & 2 deletions mk/llvm.mk
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ $$(LLVM_STAMP_$(1)): $(S)src/rustllvm/llvm-auto-clean-trigger

ifeq ($$(CFG_ENABLE_LLVM_STATIC_STDCPP),1)
LLVM_STDCPP_RUSTFLAGS_$(1) = -L "$$(dir $$(shell $$(CC_$(1)) $$(CFG_GCCISH_CFLAGS_$(1)) \
-print-file-name=libstdc++.a))"
-print-file-name=lib$(CFG_STDCPP_NAME).a))"
else
LLVM_STDCPP_RUSTFLAGS_$(1) =
endif
Expand All @@ -83,7 +83,7 @@ endif
LLVM_LINKAGE_PATH_$(1):=$$(abspath $$(RT_OUTPUT_DIR_$(1))/llvmdeps.rs)
$$(LLVM_LINKAGE_PATH_$(1)): $(S)src/etc/mklldeps.py $$(LLVM_CONFIG_$(1))
$(Q)$(CFG_PYTHON) "$$<" "$$@" "$$(LLVM_COMPONENTS)" "$$(CFG_ENABLE_LLVM_STATIC_STDCPP)" \
$$(LLVM_CONFIG_$(1))
$$(LLVM_CONFIG_$(1)) "$(CFG_STDCPP_NAME)"
endef

$(foreach host,$(CFG_HOST), \
Expand Down
9 changes: 7 additions & 2 deletions mk/tests.mk
Original file line number Diff line number Diff line change
Expand Up @@ -1046,6 +1046,10 @@ $$(call TEST_OK_FILE,$(1),$(2),$(3),rmake): \
$$(RMAKE_TESTS:%=$(3)/test/run-make/%-$(1)-T-$(2)-H-$(3).ok)
@touch $$@

$(3)/test/run-make/%-$(1)-T-$(2)-H-$(3).ok: \
export INCLUDE := $$(CFG_MSVC_INCLUDE_PATH_$$(HOST_$(3)))
$(3)/test/run-make/%-$(1)-T-$(2)-H-$(3).ok: \
export LIB := $$(CFG_MSVC_LIB_PATH_$$(HOST_$(3)))
$(3)/test/run-make/%-$(1)-T-$(2)-H-$(3).ok: \
$(S)src/test/run-make/%/Makefile \
$$(CSREQ$(1)_T_$(2)_H_$(3))
Expand All @@ -1056,15 +1060,16 @@ $(3)/test/run-make/%-$(1)-T-$(2)-H-$(3).ok: \
$$(MAKE) \
$$(HBIN$(1)_H_$(3))/rustc$$(X_$(3)) \
$(3)/test/run-make/$$* \
$$(CC_$(3)) \
'$$(CC_$(3))' \
"$$(CFG_GCCISH_CFLAGS_$(3))" \
$$(HBIN$(1)_H_$(3))/rustdoc$$(X_$(3)) \
"$$(TESTNAME)" \
$$(LD_LIBRARY_PATH_ENV_NAME$(1)_T_$(2)_H_$(3)) \
"$$(LD_LIBRARY_PATH_ENV_HOSTDIR$(1)_T_$(2)_H_$(3))" \
"$$(LD_LIBRARY_PATH_ENV_TARGETDIR$(1)_T_$(2)_H_$(3))" \
$(1) \
$$(S)
$$(S) \
$(3)
@touch -r $$@.start_time $$@ && rm $$@.start_time
else
# FIXME #11094 - The above rule doesn't work right for multiple targets
Expand Down
40 changes: 26 additions & 14 deletions src/doc/reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -1178,11 +1178,22 @@ let px: i32 = match p { Point(x, _) => x };
```

A _unit-like struct_ is a structure without any fields, defined by leaving off
the list of fields entirely. Such types will have a single value. For example:
the list of fields entirely. Such a structure implicitly defines a constant of
its type with the same name. For example:

```
# #![feature(braced_empty_structs)]
struct Cookie;
let c = [Cookie, Cookie, Cookie, Cookie];
let c = [Cookie, Cookie {}, Cookie, Cookie {}];
```

is equivalent to

```
# #![feature(braced_empty_structs)]
struct Cookie {}
const Cookie: Cookie = Cookie {};
let c = [Cookie, Cookie {}, Cookie, Cookie {}];
```

The precise memory layout of a structure is not specified. One can specify a
Expand Down Expand Up @@ -2411,6 +2422,7 @@ The currently implemented features of the reference compiler are:
terms of encapsulation).
* - `default_type_parameter_fallback` - Allows type parameter defaults to
influence type inference.
* - `braced_empty_structs` - Allows use of empty structs with braces.

If a feature is promoted to a language feature, then all existing programs will
start to receive compilation warnings about `#![feature]` directives which enabled
Expand Down Expand Up @@ -2762,7 +2774,7 @@ The following expressions are equivalent.
let x = std::ops::Range {start: 0, end: 10};
let y = 0..10;

assert_eq!(x,y);
assert_eq!(x, y);
```

### Unary operator expressions
Expand Down Expand Up @@ -3035,18 +3047,18 @@ A `loop` expression may optionally have a _label_. The label is written as
a lifetime preceding the loop expression, as in `'foo: loop{ }`. If a
label is present, then labeled `break` and `continue` expressions nested
within this loop may exit out of this loop or return control to its head.
See [Break expressions](#break-expressions) and [Continue
See [break expressions](#break-expressions) and [continue
expressions](#continue-expressions).

### Break expressions
### `break` expressions

A `break` expression has an optional _label_. If the label is absent, then
executing a `break` expression immediately terminates the innermost loop
enclosing it. It is only permitted in the body of a loop. If the label is
present, then `break 'foo` terminates the loop with label `'foo`, which need not
be the innermost label enclosing the `break` expression, but must enclose it.

### Continue expressions
### `continue` expressions

A `continue` expression has an optional _label_. If the label is absent, then
executing a `continue` expression immediately terminates the current iteration
Expand All @@ -3059,7 +3071,7 @@ innermost label enclosing the `break` expression, but must enclose it.

A `continue` expression is only permitted in the body of a loop.

### While loops
### `while` loops

A `while` loop begins by evaluating the boolean loop conditional expression.
If the loop conditional expression evaluates to `true`, the loop body block
Expand All @@ -3082,12 +3094,12 @@ Like `loop` expressions, `while` loops can be controlled with `break` or
loops](#infinite-loops), [break expressions](#break-expressions), and
[continue expressions](#continue-expressions) for more information.

### For expressions
### `for` expressions

A `for` expression is a syntactic construct for looping over elements provided
by an implementation of `std::iter::IntoIterator`.

An example of a for loop over the contents of an array:
An example of a `for` loop over the contents of an array:

```
# type Foo = i32;
Expand Down Expand Up @@ -3117,7 +3129,7 @@ Like `loop` expressions, `for` loops can be controlled with `break` or
loops](#infinite-loops), [break expressions](#break-expressions), and
[continue expressions](#continue-expressions) for more information.

### If expressions
### `if` expressions

An `if` expression is a conditional branch in program control. The form of an
`if` expression is a condition expression, followed by a consequent block, any
Expand All @@ -3129,7 +3141,7 @@ evaluates to `false`, the consequent block is skipped and any subsequent `else
if` condition is evaluated. If all `if` and `else if` conditions evaluate to
`false` then any `else` block is executed.

### Match expressions
### `match` expressions

A `match` expression branches on a *pattern*. The exact form of matching that
occurs depends on the pattern. Patterns consist of some combination of
Expand Down Expand Up @@ -3235,7 +3247,7 @@ let message = match maybe_digit {
};
```

### If let expressions
### `if let` expressions

An `if let` expression is semantically identical to an `if` expression but in place
of a condition expression it expects a refutable let statement. If the value of the
Expand All @@ -3256,15 +3268,15 @@ if let ("Ham", b) = dish {
}
```

### While let loops
### `while let` loops

A `while let` loop is semantically identical to a `while` loop but in place of a
condition expression it expects a refutable let statement. If the value of the
expression on the right hand side of the let statement matches the pattern, the
loop body block executes and control returns to the pattern matching statement.
Otherwise, the while expression completes.

### Return expressions
### `return` expressions

Return expressions are denoted with the keyword `return`. Evaluating a `return`
expression moves its argument into the designated output location for the
Expand Down
32 changes: 25 additions & 7 deletions src/doc/trpl/error-handling.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ systems may want to jump around.
* [The `Result` type](#the-result-type)
* [Parsing integers](#parsing-integers)
* [The `Result` type alias idiom](#the-result-type-alias-idiom)
* [A brief interlude: unwrapping isn't evil](#a-brief-interlude-unwrapping-isnt-evil)
* [A brief interlude: unwrapping isn't evil](#a-brief-interlude:-unwrapping-isn't-evil)
* [Working with multiple error types](#working-with-multiple-error-types)
* [Composing `Option` and `Result`](#composing-option-and-result)
* [The limits of combinators](#the-limits-of-combinators)
Expand All @@ -41,11 +41,11 @@ systems may want to jump around.
* [The real `try!` macro](#the-real-try!-macro)
* [Composing custom error types](#composing-custom-error-types)
* [Advice for library writers](#advice-for-library-writers)
* [Case study: A program to read population data](#case-study-a-program-to-read-population-data)
* [Case study: A program to read population data](#case-study:-a-program-to-read-population-data)
* [Initial setup](#initial-setup)
* [Argument parsing](#argument-parsing)
* [Writing the logic](#writing-the-logic)
* [Error handling with `Box<Error>`](#error-handling-with-box<error>)
* [Error handling with `Box<Error>`](#error-handling-with-box%3Cerror%3E)
* [Reading from stdin](#reading-from-stdin)
* [Error handling with a custom type](#error-handling-with-a-custom-type)
* [Adding functionality](#adding-functionality)
Expand Down Expand Up @@ -87,6 +87,8 @@ 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"></a>

```rust,should_panic
use std::env;

Expand Down Expand Up @@ -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]:

Expand All @@ -137,6 +139,8 @@ 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"></a>

```rust
// Searches `haystack` for the Unicode character `needle`. If one is found, the
// byte offset of the character is returned. Otherwise, `None` is returned.
Expand Down Expand Up @@ -182,6 +186,8 @@ But wait, what about `unwrap` used in [`unwrap-double`](#code-unwrap-double)?
There was no case analysis there! Instead, the case analysis was put inside the
`unwrap` method for you. You could define it yourself if you want:

<a name="code-option-def-unwrap"></a>

```rust
enum Option<T> {
None,
Expand All @@ -205,7 +211,7 @@ that makes `unwrap` ergonomic to use. Unfortunately, that `panic!` means that

### Composing `Option<T>` values

In [`option-ex-string-find`](#code-option-ex-string-find-2)
In [`option-ex-string-find`](#code-option-ex-string-find)
we saw how to use `find` to discover the extension in a file name. Of course,
not all file names have a `.` in them, so it's possible that the file name has
no extension. This *possibility of absence* is encoded into the types using
Expand Down Expand Up @@ -247,6 +253,8 @@ option is `None`, in which case, just return `None`.
Rust has parametric polymorphism, so it is very easy to define a combinator
that abstracts this pattern:

<a name="code-option-map"></a>

```rust
fn map<F, T, A>(option: Option<T>, f: F) -> Option<A> where F: FnOnce(T) -> A {
match option {
Expand Down Expand Up @@ -386,6 +394,8 @@ remove choices because they will panic if `Option<T>` is `None`.
The `Result` type is also
[defined in the standard library][6]:

<a name="code-result-def-1"></a>

```rust
enum Result<T, E> {
Ok(T),
Expand Down Expand Up @@ -662,6 +672,8 @@ with both an `Option` and a `Result`, the solution is *usually* to convert the
(from `env::args()`) means the user didn't invoke the program correctly. We
could just use a `String` to describe the error. Let's try:

<a name="code-error-double-string"></a>

```rust
use std::env;

Expand Down Expand Up @@ -894,6 +906,8 @@ seen above.

Here is a simplified definition of a `try!` macro:

<a nama name="code-try-def-simple"></a>

```rust
macro_rules! try {
($e:expr) => (match $e {
Expand Down Expand Up @@ -1154,6 +1168,8 @@ The `std::convert::From` trait is
[defined in the standard
library](../std/convert/trait.From.html):

<a name="code-from-def"></a>

```rust
trait From<T> {
fn from(T) -> Self;
Expand Down Expand Up @@ -1231,9 +1247,11 @@ macro_rules! try {
}
```

This is not it's real definition. It's real definition is
This is not its real definition. Its real definition is
[in the standard library](../std/macro.try!.html):

<a name="code-try-def"></a>

```rust
macro_rules! try {
($e:expr) => (match $e {
Expand Down Expand Up @@ -1452,7 +1470,7 @@ representation. But certainly, this will vary depending on use cases.
At a minimum, you should probably implement the
[`Error`](../std/error/trait.Error.html)
trait. This will give users of your library some minimum flexibility for
[composing errors](#the-real-try-macro). Implementing the `Error` trait also
[composing errors](#the-real-try!-macro). Implementing the `Error` trait also
means that users are guaranteed the ability to obtain a string representation
of an error (because it requires impls for both `fmt::Debug` and
`fmt::Display`).
Expand Down
Loading