Skip to content

Commit

Permalink
Fix up even more links in the first edition.
Browse files Browse the repository at this point in the history
  • Loading branch information
steveklabnik committed Mar 15, 2017
1 parent bd8d27b commit 23a7a7b
Show file tree
Hide file tree
Showing 25 changed files with 124 additions and 124 deletions.
8 changes: 4 additions & 4 deletions first-edition/src/borrow-and-asref.md
Expand Up @@ -3,8 +3,8 @@
The [`Borrow`][borrow] and [`AsRef`][asref] traits are very similar, but
different. Here’s a quick refresher on what these two traits mean.

[borrow]: ../std/borrow/trait.Borrow.html
[asref]: ../std/convert/trait.AsRef.html
[borrow]: ../../std/borrow/trait.Borrow.html
[asref]: ../../std/convert/trait.AsRef.html

# Borrow

Expand All @@ -19,8 +19,8 @@ fn get<Q: ?Sized>(&self, k: &Q) -> Option<&V>
Q: Hash + Eq
```

[hashmap]: ../std/collections/struct.HashMap.html
[get]: ../std/collections/struct.HashMap.html#method.get
[hashmap]: ../../std/collections/struct.HashMap.html
[get]: ../../std/collections/struct.HashMap.html#method.get

This signature is pretty complicated. The `K` parameter is what we’re interested
in here. It refers to a parameter of the `HashMap` itself:
Expand Down
18 changes: 9 additions & 9 deletions first-edition/src/choosing-your-guarantees.md
Expand Up @@ -38,7 +38,7 @@ This is a zero-cost abstraction for dynamic allocation. If you want to allocate
heap and safely pass around a pointer to that memory, this is ideal. Note that you will only be
allowed to share references to this by the regular borrowing rules, checked at compile time.

[box]: ../std/boxed/struct.Box.html
[box]: ../../std/boxed/struct.Box.html

## `&T` and `&mut T`

Expand Down Expand Up @@ -104,7 +104,7 @@ two `usize` values) as compared to a regular `Box<T>` (for "strong" and "weak" r
or goes out of scope respectively. Note that a clone will not do a deep copy, rather it will simply
increment the inner reference count and return a copy of the `Rc<T>`.

[rc]: ../std/rc/struct.Rc.html
[rc]: ../../std/rc/struct.Rc.html

# Cell types

Expand Down Expand Up @@ -234,9 +234,9 @@ indicator (one word in size) along with the data.

At runtime each borrow causes a modification/check of the refcount.

[cell-mod]: ../std/cell/index.html
[cell]: ../std/cell/struct.Cell.html
[refcell]: ../std/cell/struct.RefCell.html
[cell-mod]: ../../std/cell/index.html
[cell]: ../../std/cell/struct.Cell.html
[refcell]: ../../std/cell/struct.RefCell.html

# Synchronous types

Expand All @@ -252,7 +252,7 @@ time.
There are many useful wrappers for concurrent programming in the [sync][sync] module, but only the
major ones will be covered below.

[sync]: ../std/sync/index.html
[sync]: ../../std/sync/index.html

## `Arc<T>`

Expand Down Expand Up @@ -280,7 +280,7 @@ This has the added cost of using atomics for changing the refcount (which will h
cloned or goes out of scope). When sharing data from an `Arc` in a single thread, it is preferable
to share `&` pointers whenever possible.

[arc]: ../std/sync/struct.Arc.html
[arc]: ../../std/sync/struct.Arc.html

## `Mutex<T>` and `RwLock<T>`

Expand Down Expand Up @@ -316,8 +316,8 @@ These use internal atomic-like types to maintain the locks, which are pretty cos
all memory reads across processors till they're done). Waiting on these locks can also be slow when
there's a lot of concurrent access happening.

[rwlock]: ../std/sync/struct.RwLock.html
[mutex]: ../std/sync/struct.Mutex.html
[rwlock]: ../../std/sync/struct.RwLock.html
[mutex]: ../../std/sync/struct.Mutex.html
[sessions]: https://github.com/Munksgaard/rust-sessions

# Composition
Expand Down
8 changes: 4 additions & 4 deletions first-edition/src/concurrency.md
Expand Up @@ -26,7 +26,7 @@ to help us make sense of code that can possibly be concurrent.
### `Send`

The first trait we're going to talk about is
[`Send`](../std/marker/trait.Send.html). When a type `T` implements `Send`, it
[`Send`](../../std/marker/trait.Send.html). When a type `T` implements `Send`, it
indicates that something of this type is able to have ownership transferred
safely between threads.

Expand All @@ -43,7 +43,7 @@ us enforce that it can't leave the current thread.

### `Sync`

The second of these traits is called [`Sync`](../std/marker/trait.Sync.html).
The second of these traits is called [`Sync`](../../std/marker/trait.Sync.html).
When a type `T` implements `Sync`, it indicates that something
of this type has no possibility of introducing memory unsafety when used from
multiple threads concurrently through shared references. This implies that
Expand Down Expand Up @@ -333,8 +333,8 @@ locked, it will wait until the other thread releases the lock.
The lock "release" here is implicit; when the result of the lock (in this case,
`data`) goes out of scope, the lock is automatically released.

Note that [`lock`](../std/sync/struct.Mutex.html#method.lock) method of
[`Mutex`](../std/sync/struct.Mutex.html) has this signature:
Note that [`lock`](../../std/sync/struct.Mutex.html#method.lock) method of
[`Mutex`](../../std/sync/struct.Mutex.html) has this signature:

```rust,ignore
fn lock(&self) -> LockResult<MutexGuard<T>>
Expand Down
68 changes: 34 additions & 34 deletions first-edition/src/error-handling.md
Expand Up @@ -1113,7 +1113,7 @@ The first two are a result of `Error` requiring impls for both `Debug` and
`Display`. The latter two are from the two methods defined on `Error`. The
power of `Error` comes from the fact that all error types impl `Error`, which
means errors can be existentially quantified as a
[trait object](../book/trait-objects.html).
[trait object](../book/first-edition/trait-objects.html).
This manifests as either `Box<Error>` or `&Error`. Indeed, the `cause` method
returns an `&Error`, which is itself a trait object. We'll revisit the
`Error` trait's utility as a trait object later.
Expand Down Expand Up @@ -1189,7 +1189,7 @@ different error types and satisfy the contracts defined for `description` and

The `std::convert::From` trait is
[defined in the standard
library](../std/convert/trait.From.html):
library](../../std/convert/trait.From.html):

<span id="code-from-def"></span>

Expand All @@ -1204,7 +1204,7 @@ way to talk about conversion *from* a particular type `T` to some other type
(in this case, “some other type” is the subject of the impl, or `Self`).
The crux of `From` is the
[set of implementations provided by the standard
library](../std/convert/trait.From.html).
library](../../std/convert/trait.From.html).

Here are a few simple examples demonstrating how `From` works:

Expand Down Expand Up @@ -1271,7 +1271,7 @@ macro_rules! try {
```

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

<span id="code-try-def"></span>

Expand Down Expand Up @@ -1340,8 +1340,8 @@ There's one little nit left: the `Box<Error>` type is *opaque*. If we
return a `Box<Error>` to the caller, the caller can't (easily) inspect
underlying error type. The situation is certainly better than `String`
because the caller can call methods like
[`description`](../std/error/trait.Error.html#tymethod.description)
and [`cause`](../std/error/trait.Error.html#method.cause), but the
[`description`](../../std/error/trait.Error.html#tymethod.description)
and [`cause`](../../std/error/trait.Error.html#method.cause), but the
limitation remains: `Box<Error>` is opaque. (N.B. This isn't entirely
true because Rust does have runtime reflection, which is useful in
some scenarios that are [beyond the scope of this
Expand Down Expand Up @@ -1484,14 +1484,14 @@ And that's it!
If your library needs to report custom errors, then you should
probably define your own error type. It's up to you whether or not to
expose its representation (like
[`ErrorKind`](../std/io/enum.ErrorKind.html)) or keep it hidden (like
[`ParseIntError`](../std/num/struct.ParseIntError.html)). Regardless
[`ErrorKind`](../../std/io/enum.ErrorKind.html)) or keep it hidden (like
[`ParseIntError`](../../std/num/struct.ParseIntError.html)). Regardless
of how you do it, it's usually good practice to at least provide some
information about the error beyond its `String`
representation. But certainly, this will vary depending on use cases.

At a minimum, you should probably implement the
[`Error`](../std/error/trait.Error.html)
[`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
means that users are guaranteed the ability to obtain a string representation
Expand All @@ -1507,8 +1507,8 @@ provides `From` impls for both `io::Error` and `byteorder::Error`.
Finally, depending on your tastes, you may also want to define a
[`Result` type alias](#the-result-type-alias-idiom), particularly if your
library defines a single error type. This is used in the standard library
for [`io::Result`](../std/io/type.Result.html)
and [`fmt::Result`](../std/fmt/type.Result.html).
for [`io::Result`](../../std/io/type.Result.html)
and [`fmt::Result`](../../std/fmt/type.Result.html).

# Case study: A program to read population data

Expand Down Expand Up @@ -1702,9 +1702,9 @@ fn main() {
Let's outline the errors. We can start with the obvious: the three places that
`unwrap` is called:

1. [`File::open`](../std/fs/struct.File.html#method.open)
1. [`File::open`](../../std/fs/struct.File.html#method.open)
can return an
[`io::Error`](../std/io/struct.Error.html).
[`io::Error`](../../std/io/struct.Error.html).
2. [`csv::Reader::decode`](http://burntsushi.net/rustdoc/csv/struct.Reader.html#method.decode)
decodes one record at a time, and
[decoding a
Expand Down Expand Up @@ -1859,7 +1859,7 @@ Instead of `x.unwrap()`, we now have `try!(x)`. Since our function returns a
error occurs.

At the end of `search` we also convert a plain string to an error type
by using the [corresponding `From` impls](../std/convert/trait.From.html):
by using the [corresponding `From` impls](../../std/convert/trait.From.html):

```rust,ignore
// We are making use of this impl in the code above, since we call `From::from`
Expand Down Expand Up @@ -2162,10 +2162,10 @@ heuristics!

* If you're writing short example code that would be overburdened by error
handling, it's probably fine to use `unwrap` (whether that's
[`Result::unwrap`](../std/result/enum.Result.html#method.unwrap),
[`Option::unwrap`](../std/option/enum.Option.html#method.unwrap)
[`Result::unwrap`](../../std/result/enum.Result.html#method.unwrap),
[`Option::unwrap`](../../std/option/enum.Option.html#method.unwrap)
or preferably
[`Option::expect`](../std/option/enum.Option.html#method.expect)).
[`Option::expect`](../../std/option/enum.Option.html#method.expect)).
Consumers of your code should know to use proper error handling. (If they
don't, send them here!)
* If you're writing a quick 'n' dirty program, don't feel ashamed if you use
Expand All @@ -2175,37 +2175,37 @@ heuristics!
anyway, then use either a `String` or a `Box<Error>` for your
error type.
* Otherwise, in a program, define your own error types with appropriate
[`From`](../std/convert/trait.From.html)
[`From`](../../std/convert/trait.From.html)
and
[`Error`](../std/error/trait.Error.html)
impls to make the [`try!`](../std/macro.try.html)
[`Error`](../../std/error/trait.Error.html)
impls to make the [`try!`](../../std/macro.try.html)
macro more ergonomic.
* If you're writing a library and your code can produce errors, define your own
error type and implement the
[`std::error::Error`](../std/error/trait.Error.html)
[`std::error::Error`](../../std/error/trait.Error.html)
trait. Where appropriate, implement
[`From`](../std/convert/trait.From.html) to make both
[`From`](../../std/convert/trait.From.html) to make both
your library code and the caller's code easier to write. (Because of Rust's
coherence rules, callers will not be able to impl `From` on your error type,
so your library should do it.)
* Learn the combinators defined on
[`Option`](../std/option/enum.Option.html)
[`Option`](../../std/option/enum.Option.html)
and
[`Result`](../std/result/enum.Result.html).
[`Result`](../../std/result/enum.Result.html).
Using them exclusively can be a bit tiring at times, but I've personally
found a healthy mix of `try!` and combinators to be quite appealing.
`and_then`, `map` and `unwrap_or` are my favorites.

[1]: ../book/patterns.html
[2]: ../std/option/enum.Option.html#method.map
[3]: ../std/option/enum.Option.html#method.unwrap_or
[4]: ../std/option/enum.Option.html#method.unwrap_or_else
[5]: ../std/option/enum.Option.html
[6]: ../std/result/index.html
[7]: ../std/result/enum.Result.html#method.unwrap
[8]: ../std/fmt/trait.Debug.html
[9]: ../std/primitive.str.html#method.parse
[10]: ../book/associated-types.html
[1]: ../book/first-edition/patterns.html
[2]: ../../std/option/enum.Option.html#method.map
[3]: ../../std/option/enum.Option.html#method.unwrap_or
[4]: ../../std/option/enum.Option.html#method.unwrap_or_else
[5]: ../../std/option/enum.Option.html
[6]: ../../std/result/index.html
[7]: ../../std/result/enum.Result.html#method.unwrap
[8]: ../../std/fmt/trait.Debug.html
[9]: ../../std/primitive.str.html#method.parse
[10]: ../book/first-edition/associated-types.html
[11]: https://github.com/petewarden/dstkdata
[12]: http://burntsushi.net/stuff/worldcitiespop.csv.gz
[13]: http://burntsushi.net/stuff/uscitiespop.csv.gz
Expand Down
4 changes: 2 additions & 2 deletions first-edition/src/ffi.md
Expand Up @@ -246,7 +246,7 @@ Foreign libraries often hand off ownership of resources to the calling code.
When this occurs, we must use Rust's destructors to provide safety and guarantee
the release of these resources (especially in the case of panic).

For more about destructors, see the [Drop trait](../std/ops/trait.Drop.html).
For more about destructors, see the [Drop trait](../../std/ops/trait.Drop.html).

# Callbacks from C code to Rust functions

Expand Down Expand Up @@ -710,7 +710,7 @@ Please note that [`catch_unwind()`] will only catch unwinding panics, not
those who abort the process. See the documentation of [`catch_unwind()`]
for more information.

[`catch_unwind()`]: ../std/panic/fn.catch_unwind.html
[`catch_unwind()`]: ../../std/panic/fn.catch_unwind.html

# Representing opaque structs

Expand Down
4 changes: 2 additions & 2 deletions first-edition/src/generics.md
Expand Up @@ -186,5 +186,5 @@ functions or methods. See [Iterators § Consumers](iterators.html#consumers)
for an example.

[traits]: traits.html
[Vec]: ../std/vec/struct.Vec.html
[turbofish]: https://doc.rust-lang.org/std/iter/trait.Iterator.html#method.collect
[Vec]: ../../std/vec/struct.Vec.html
[turbofish]: ../../std/iter/trait.Iterator.html#method.collect
2 changes: 1 addition & 1 deletion first-edition/src/glossary.md
Expand Up @@ -56,7 +56,7 @@ They can be used to manage control flow in a modular fashion.

A type without a statically known size or alignment. ([more info][link])

[link]: ../nomicon/exotic-sizes.html#dynamically-sized-types-dsts
[link]: ../../nomicon/exotic-sizes.html#dynamically-sized-types-dsts

### Expression

Expand Down
20 changes: 10 additions & 10 deletions first-edition/src/guessing-game.md
Expand Up @@ -106,8 +106,8 @@ prelude, you’ll have to `use` it directly. There is also a second ‘prelude
[`io` prelude][ioprelude], which serves a similar function: you import it, and it
imports a number of useful, `io`-related things.

[prelude]: ../std/prelude/index.html
[ioprelude]: ../std/io/prelude/index.html
[prelude]: ../../std/prelude/index.html
[ioprelude]: ../../std/io/prelude/index.html

```rust,ignore
fn main() {
Expand Down Expand Up @@ -177,7 +177,7 @@ bound to: `String::new()`.
`String` is a string type, provided by the standard library. A
[`String`][string] is a growable, UTF-8 encoded bit of text.

[string]: ../std/string/struct.String.html
[string]: ../../std/string/struct.String.html

The `::new()` syntax uses `::` because this is an ‘associated function’ of
a particular type. That is to say, it’s associated with `String` itself,
Expand Down Expand Up @@ -209,7 +209,7 @@ have written this line as `std::io::stdin()`.
This particular function returns a handle to the standard input for your
terminal. More specifically, a [std::io::Stdin][iostdin].

[iostdin]: ../std/io/struct.Stdin.html
[iostdin]: ../../std/io/struct.Stdin.html

The next part will use this handle to get input from the user:

Expand All @@ -222,7 +222,7 @@ Here, we call the [`read_line()`][read_line] method on our handle.
particular instance of a type, rather than the type itself. We’re also passing
one argument to `read_line()`: `&mut guess`.

[read_line]: ../std/io/struct.Stdin.html#method.read_line
[read_line]: ../../std/io/struct.Stdin.html#method.read_line
[method]: method-syntax.html

Remember how we bound `guess` above? We said it was mutable. However,
Expand Down Expand Up @@ -266,8 +266,8 @@ String` we pass it. But it also returns a value: in this case, an
standard library: a generic [`Result`][result], and then specific versions for
sub-libraries, like `io::Result`.

[ioresult]: ../std/io/type.Result.html
[result]: ../std/result/enum.Result.html
[ioresult]: ../../std/io/type.Result.html
[result]: ../../std/result/enum.Result.html

The purpose of these `Result` types is to encode error handling information.
Values of the `Result` type, like any type, have methods defined on them. In
Expand All @@ -276,7 +276,7 @@ it’s called on, and if it isn’t a successful one, [`panic!`][panic]s with a
message you passed it. A `panic!` like this will cause our program to crash,
displaying the message.

[expect]: ../std/result/enum.Result.html#method.expect
[expect]: ../../std/result/enum.Result.html#method.expect
[panic]: error-handling.html

If we do not call `expect()`, our program will compile, but
Expand Down Expand Up @@ -620,7 +620,7 @@ match guess.cmp(&secret_number) {
}
```

[ordering]: ../std/cmp/enum.Ordering.html
[ordering]: ../../std/cmp/enum.Ordering.html

If it’s `Less`, we print `Too small!`, if it’s `Greater`, `Too big!`, and if
`Equal`, `You win!`. `match` is really useful, and is used often in Rust.
Expand Down Expand Up @@ -726,7 +726,7 @@ exact type of number we want. Hence, `let guess: u32`. The colon (`:`) after
thirty-two bit integer. Rust has [a number of built-in number types][number],
but we’ve chosen `u32`. It’s a good default choice for a small positive number.
[parse]: ../std/primitive.str.html#method.parse
[parse]: ../../std/primitive.str.html#method.parse
[number]: primitive-types.html#numeric-types
Just like `read_line()`, our call to `parse()` could cause an error. What if
Expand Down
2 changes: 1 addition & 1 deletion first-edition/src/iterators.md
Expand Up @@ -341,4 +341,4 @@ can help you with. There are a number of really useful iterators, and you can
write your own as well. Iterators provide a safe, efficient way to manipulate
all kinds of lists. They're a little unusual at first, but if you play with
them, you'll get hooked. For a full list of the different iterators and
consumers, check out the [iterator module documentation](../std/iter/index.html).
consumers, check out the [iterator module documentation](../../std/iter/index.html).

0 comments on commit 23a7a7b

Please sign in to comment.