Revert "Fix up links"
This reverts commit 7f1d1c6d9a
.
The original commit was created because mdBook and rustdoc had
different generation algorithms for header links; now with
https://github.com/rust-lang/rust/pull/39966 , the algorithms
are the same. So let's undo this change.
... when I came across this problem, I said "eh, this isn't fun,
but it doesn't take that long." I probably should have just actually
taken the time to fix upstream, given that they were amenable. Oh
well!
This commit is contained in:
parent
941d494a6a
commit
b4cd3d9206
27 changed files with 96 additions and 96 deletions
|
@ -8,7 +8,7 @@ most dangerous features of Rust!
|
||||||
# Coercion
|
# Coercion
|
||||||
|
|
||||||
Coercion between types is implicit and has no syntax of its own, but can
|
Coercion between types is implicit and has no syntax of its own, but can
|
||||||
be spelled out with [`as`](#Explicit%20coercions).
|
be spelled out with [`as`](#explicit-coercions).
|
||||||
|
|
||||||
Coercion occurs in `let`, `const`, and `static` statements; in
|
Coercion occurs in `let`, `const`, and `static` statements; in
|
||||||
function call arguments; in field values in struct initialization; and in a
|
function call arguments; in field values in struct initialization; and in a
|
||||||
|
|
|
@ -463,7 +463,7 @@ fn factory() -> &(Fn(i32) -> i32) {
|
||||||
|
|
||||||
Right. Because we have a reference, we need to give it a lifetime. But
|
Right. Because we have a reference, we need to give it a lifetime. But
|
||||||
our `factory()` function takes no arguments, so
|
our `factory()` function takes no arguments, so
|
||||||
[elision](lifetimes.html#Lifetime%20Elision) doesn’t kick in here. Then what
|
[elision](lifetimes.html#lifetime-elision) doesn’t kick in here. Then what
|
||||||
choices do we have? Try `'static`:
|
choices do we have? Try `'static`:
|
||||||
|
|
||||||
```rust,ignore
|
```rust,ignore
|
||||||
|
|
|
@ -127,7 +127,7 @@ enum. For a more involved macro example, see
|
||||||
|
|
||||||
## Tips and tricks
|
## Tips and tricks
|
||||||
|
|
||||||
Some of the [macro debugging tips](macros.html#Debugging%20macro%20code) are applicable.
|
Some of the [macro debugging tips](macros.html#debugging-macro-code) are applicable.
|
||||||
|
|
||||||
You can use `syntax::parse` to turn token trees into
|
You can use `syntax::parse` to turn token trees into
|
||||||
higher-level syntax elements like expressions:
|
higher-level syntax elements like expressions:
|
||||||
|
|
|
@ -55,7 +55,7 @@ For sharing references across threads, Rust provides a wrapper type called
|
||||||
`Arc<T>`. `Arc<T>` implements `Send` and `Sync` if and only if `T` implements
|
`Arc<T>`. `Arc<T>` implements `Send` and `Sync` if and only if `T` implements
|
||||||
both `Send` and `Sync`. For example, an object of type `Arc<RefCell<U>>` cannot
|
both `Send` and `Sync`. For example, an object of type `Arc<RefCell<U>>` cannot
|
||||||
be transferred across threads because
|
be transferred across threads because
|
||||||
[`RefCell`](choosing-your-guarantees.html#RefCell%3CT%3E) does not implement
|
[`RefCell`](choosing-your-guarantees.html#refcellt) does not implement
|
||||||
`Sync`, consequently `Arc<RefCell<U>>` would not implement `Send`.
|
`Sync`, consequently `Arc<RefCell<U>>` would not implement `Send`.
|
||||||
|
|
||||||
These two traits allow you to use the type system to make strong guarantees
|
These two traits allow you to use the type system to make strong guarantees
|
||||||
|
@ -126,7 +126,7 @@ closure only captures a _reference to `x`_. This is a problem, because the
|
||||||
thread may outlive the scope of `x`, leading to a dangling pointer.
|
thread may outlive the scope of `x`, leading to a dangling pointer.
|
||||||
|
|
||||||
To fix this, we use a `move` closure as mentioned in the error message. `move`
|
To fix this, we use a `move` closure as mentioned in the error message. `move`
|
||||||
closures are explained in depth [here](closures.html#move%20closures); basically
|
closures are explained in depth [here](closures.html#move-closures); basically
|
||||||
they move variables from their environment into themselves.
|
they move variables from their environment into themselves.
|
||||||
|
|
||||||
```rust
|
```rust
|
||||||
|
|
|
@ -21,35 +21,35 @@ sum types and combinators, and try to motivate the way Rust does error handling
|
||||||
incrementally. As such, programmers with experience in other expressive type
|
incrementally. As such, programmers with experience in other expressive type
|
||||||
systems may want to jump around.
|
systems may want to jump around.
|
||||||
|
|
||||||
* [The Basics](#The%20Basics)
|
* [The Basics](#the-basics)
|
||||||
* [Unwrapping explained](#Unwrapping%20explained)
|
* [Unwrapping explained](#unwrapping-explained)
|
||||||
* [The `Option` type](#The%20Option%20type)
|
* [The `Option` type](#the-option-type)
|
||||||
* [Composing `Option<T>` values](#Composing%20Option%3CT%3E%20values)
|
* [Composing `Option<T>` values](#composing-optiont-values)
|
||||||
* [The `Result` type](#The%20Result%20type)
|
* [The `Result` type](#the-result-type)
|
||||||
* [Parsing integers](#Parsing%20integers)
|
* [Parsing integers](#parsing-integers)
|
||||||
* [The `Result` type alias idiom](#The%20Result%20type%20alias%20idiom)
|
* [The `Result` type alias idiom](#the-result-type-alias-idiom)
|
||||||
* [A brief interlude: unwrapping isn't evil](#A%20brief%20interlude:%20unwrapping%20isnt%20evil)
|
* [A brief interlude: unwrapping isn't evil](#a-brief-interlude-unwrapping-isnt-evil)
|
||||||
* [Working with multiple error types](#Working%20with%20multiple%20error%20types)
|
* [Working with multiple error types](#working-with-multiple-error-types)
|
||||||
* [Composing `Option` and `Result`](#Composing%20Option%20and%20Result)
|
* [Composing `Option` and `Result`](#composing-option-and-result)
|
||||||
* [The limits of combinators](#The%20limits%20of%20combinators)
|
* [The limits of combinators](#the-limits-of-combinators)
|
||||||
* [Early returns](#Early%20returns)
|
* [Early returns](#early-returns)
|
||||||
* [The `try!` macro](#The%20try%20macro)
|
* [The `try!` macro](#the-try-macro)
|
||||||
* [Defining your own error type](#Defining%20your%20own%20error%20type)
|
* [Defining your own error type](#defining-your-own-error-type)
|
||||||
* [Standard library traits used for error handling](#Standard%20library%20traits%20used%20for%20error%20handling)
|
* [Standard library traits used for error handling](#standard-library-traits-used-for-error-handling)
|
||||||
* [The `Error` trait](#The%20Error%20trait)
|
* [The `Error` trait](#the-error-trait)
|
||||||
* [The `From` trait](#The%20From%20trait)
|
* [The `From` trait](#the-from-trait)
|
||||||
* [The real `try!` macro](#The%20real%20try%20macro)
|
* [The real `try!` macro](#the-real-try-macro)
|
||||||
* [Composing custom error types](#Composing%20custom%20error%20types)
|
* [Composing custom error types](#composing-custom-error-types)
|
||||||
* [Advice for library writers](#Advice%20for%20library%20writers)
|
* [Advice for library writers](#advice-for-library-writers)
|
||||||
* [Case study: A program to read population data](#Case%20study:%20A%20program%20to%20read%20population%20data)
|
* [Case study: A program to read population data](#case-study-a-program-to-read-population-data)
|
||||||
* [Initial setup](#Initial%20setup)
|
* [Initial setup](#initial-setup)
|
||||||
* [Argument parsing](#Argument%20parsing)
|
* [Argument parsing](#argument-parsing)
|
||||||
* [Writing the logic](#Writing%20the%20logic)
|
* [Writing the logic](#writing-the-logic)
|
||||||
* [Error handling with `Box<Error>`](#Error%20handling%20with%20Box%3CError%3E)
|
* [Error handling with `Box<Error>`](#error-handling-with-boxerror)
|
||||||
* [Reading from stdin](#Reading%20from%20stdin)
|
* [Reading from stdin](#reading-from-stdin)
|
||||||
* [Error handling with a custom type](#Error%20handling%20with%20a%20custom%20type)
|
* [Error handling with a custom type](#error-handling-with-a-custom-type)
|
||||||
* [Adding functionality](#Adding%20functionality)
|
* [Adding functionality](#adding-functionality)
|
||||||
* [The short story](#The%20short%20story)
|
* [The short story](#the-short-story)
|
||||||
|
|
||||||
# The Basics
|
# The Basics
|
||||||
|
|
||||||
|
@ -796,7 +796,7 @@ because of the return types of
|
||||||
[`std::fs::File::open`](../std/fs/struct.File.html#method.open) and
|
[`std::fs::File::open`](../std/fs/struct.File.html#method.open) and
|
||||||
[`std::io::Read::read_to_string`](../std/io/trait.Read.html#method.read_to_string).
|
[`std::io::Read::read_to_string`](../std/io/trait.Read.html#method.read_to_string).
|
||||||
(Note that they both use the [`Result` type alias
|
(Note that they both use the [`Result` type alias
|
||||||
idiom](#The%20Result%20type%20alias%20idiom) described previously. If you
|
idiom](#the-result-type-alias-idiom) described previously. If you
|
||||||
click on the `Result` type, you'll [see the type
|
click on the `Result` type, you'll [see the type
|
||||||
alias](../std/io/type.Result.html), and consequently, the underlying
|
alias](../std/io/type.Result.html), and consequently, the underlying
|
||||||
`io::Error` type.) The third problem is described by the
|
`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
|
||||||
|
|
||||||
For now, it suffices to show an example implementing the `Error` trait. Let's
|
For now, it suffices to show an example implementing the `Error` trait. Let's
|
||||||
use the error type we defined in the
|
use the error type we defined in the
|
||||||
[previous section](#Defining%20your%20own%20error%20type):
|
[previous section](#defining-your-own-error-type):
|
||||||
|
|
||||||
```rust
|
```rust
|
||||||
use std::io;
|
use std::io;
|
||||||
|
@ -1493,19 +1493,19 @@ representation. But certainly, this will vary depending on use cases.
|
||||||
At a minimum, you should probably implement the
|
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
|
trait. This will give users of your library some minimum flexibility for
|
||||||
[composing errors](#The%20real%20try%20macro). 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
|
means that users are guaranteed the ability to obtain a string representation
|
||||||
of an error (because it requires impls for both `fmt::Debug` and
|
of an error (because it requires impls for both `fmt::Debug` and
|
||||||
`fmt::Display`).
|
`fmt::Display`).
|
||||||
|
|
||||||
Beyond that, it can also be useful to provide implementations of `From` on your
|
Beyond that, it can also be useful to provide implementations of `From` on your
|
||||||
error types. This allows you (the library author) and your users to
|
error types. This allows you (the library author) and your users to
|
||||||
[compose more detailed errors](#Composing%20custom%20error%20types). For example,
|
[compose more detailed errors](#composing-custom-error-types). For example,
|
||||||
[`csv::Error`](http://burntsushi.net/rustdoc/csv/enum.Error.html)
|
[`csv::Error`](http://burntsushi.net/rustdoc/csv/enum.Error.html)
|
||||||
provides `From` impls for both `io::Error` and `byteorder::Error`.
|
provides `From` impls for both `io::Error` and `byteorder::Error`.
|
||||||
|
|
||||||
Finally, depending on your tastes, you may also want to define a
|
Finally, depending on your tastes, you may also want to define a
|
||||||
[`Result` type alias](#The%20Result%20type%20alias%20idiom), particularly if your
|
[`Result` type alias](#the-result-type-alias-idiom), particularly if your
|
||||||
library defines a single error type. This is used in the standard library
|
library defines a single error type. This is used in the standard library
|
||||||
for [`io::Result`](../std/io/type.Result.html)
|
for [`io::Result`](../std/io/type.Result.html)
|
||||||
and [`fmt::Result`](../std/fmt/type.Result.html).
|
and [`fmt::Result`](../std/fmt/type.Result.html).
|
||||||
|
@ -1538,7 +1538,7 @@ and [`rustc-serialize`](https://crates.io/crates/rustc-serialize) crates.
|
||||||
|
|
||||||
We're not going to spend a lot of time on setting up a project with
|
We're not going to spend a lot of time on setting up a project with
|
||||||
Cargo because it is already covered well in [the Cargo
|
Cargo because it is already covered well in [the Cargo
|
||||||
section](getting-started.html#Hello%20Cargo) and [Cargo's documentation][14].
|
section](getting-started.html#hello-cargo) and [Cargo's documentation][14].
|
||||||
|
|
||||||
To get started from scratch, run `cargo new --bin city-pop` and make sure your
|
To get started from scratch, run `cargo new --bin city-pop` and make sure your
|
||||||
`Cargo.toml` looks something like this:
|
`Cargo.toml` looks something like this:
|
||||||
|
@ -1729,7 +1729,7 @@ error types and you don't need any `From` implementations. The downside is that
|
||||||
since `Box<Error>` is a trait object, it *erases the type*, which means the
|
since `Box<Error>` is a trait object, it *erases the type*, which means the
|
||||||
compiler can no longer reason about its underlying type.
|
compiler can no longer reason about its underlying type.
|
||||||
|
|
||||||
[Previously](#The%20limits%20of%20combinators) we started refactoring our code by
|
[Previously](#the-limits-of-combinators) we started refactoring our code by
|
||||||
changing the type of our function from `T` to `Result<T, OurErrorType>`. In
|
changing the type of our function from `T` to `Result<T, OurErrorType>`. In
|
||||||
this case, `OurErrorType` is only `Box<Error>`. But what's `T`? And can we add
|
this case, `OurErrorType` is only `Box<Error>`. But what's `T`? And can we add
|
||||||
a return type to `main`?
|
a return type to `main`?
|
||||||
|
|
|
@ -680,7 +680,7 @@ pub extern fn hello_rust() -> *const u8 {
|
||||||
|
|
||||||
The `extern` makes this function adhere to the C calling convention, as
|
The `extern` makes this function adhere to the C calling convention, as
|
||||||
discussed above in "[Foreign Calling
|
discussed above in "[Foreign Calling
|
||||||
Conventions](ffi.html#Foreign%20calling%20conventions)". The `no_mangle`
|
Conventions](ffi.html#foreign-calling-conventions)". The `no_mangle`
|
||||||
attribute turns off Rust's name mangling, so that it is easier to link to.
|
attribute turns off Rust's name mangling, so that it is easier to link to.
|
||||||
|
|
||||||
# FFI and panics
|
# FFI and panics
|
||||||
|
|
|
@ -236,7 +236,7 @@ language]*, which means that most things are expressions, rather than
|
||||||
statements. The `;` indicates that this expression is over, and the next one is
|
statements. The `;` indicates that this expression is over, and the next one is
|
||||||
ready to begin. Most lines of Rust code end with a `;`.
|
ready to begin. Most lines of Rust code end with a `;`.
|
||||||
|
|
||||||
[expression-oriented language]: glossary.html#Expression-Oriented%20Language
|
[expression-oriented language]: glossary.html#expression-oriented-language
|
||||||
|
|
||||||
## Compiling and Running Are Separate Steps
|
## Compiling and Running Are Separate Steps
|
||||||
|
|
||||||
|
|
|
@ -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])
|
A type without a statically known size or alignment. ([more info][link])
|
||||||
|
|
||||||
[link]: ../nomicon/exotic-sizes.html#Dynamically%20Sized%20Types%20(DSTs)
|
[link]: ../nomicon/exotic-sizes.html#dynamically-sized-types-dsts
|
||||||
|
|
||||||
### Expression
|
### Expression
|
||||||
|
|
||||||
|
@ -76,8 +76,8 @@ In an expression-oriented language, (nearly) every statement is an expression
|
||||||
and therefore returns a value. Consequently, these expression statements can
|
and therefore returns a value. Consequently, these expression statements can
|
||||||
themselves form part of larger expressions.
|
themselves form part of larger expressions.
|
||||||
|
|
||||||
[expression]: glossary.html#Expression
|
[expression]: glossary.html#expression
|
||||||
[statement]: glossary.html#Statement
|
[statement]: glossary.html#statement
|
||||||
|
|
||||||
### Statement
|
### Statement
|
||||||
|
|
||||||
|
|
|
@ -119,7 +119,7 @@ there are no arguments, and `{` starts the body of the function. Because
|
||||||
we didn’t include a return type, it’s assumed to be `()`, an empty
|
we didn’t include a return type, it’s assumed to be `()`, an empty
|
||||||
[tuple][tuples].
|
[tuple][tuples].
|
||||||
|
|
||||||
[tuples]: primitive-types.html#Tuples
|
[tuples]: primitive-types.html#tuples
|
||||||
|
|
||||||
```rust,ignore
|
```rust,ignore
|
||||||
println!("Guess the number!");
|
println!("Guess the number!");
|
||||||
|
@ -727,7 +727,7 @@ 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.
|
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%20types
|
[number]: primitive-types.html#numeric-types
|
||||||
|
|
||||||
Just like `read_line()`, our call to `parse()` could cause an error. What if
|
Just like `read_line()`, our call to `parse()` could cause an error. What if
|
||||||
our string contained `A👍%`? There’d be no way to convert that to a number. As
|
our string contained `A👍%`? There’d be no way to convert that to a number. As
|
||||||
|
|
|
@ -139,7 +139,7 @@ associated with it, but the compiler lets you elide (i.e. omit, see
|
||||||
["Lifetime Elision"][lifetime-elision] below) them in common cases. Before we
|
["Lifetime Elision"][lifetime-elision] below) them in common cases. Before we
|
||||||
get to that, though, let’s look at a short example with explicit lifetimes:
|
get to that, though, let’s look at a short example with explicit lifetimes:
|
||||||
|
|
||||||
[lifetime-elision]: #Lifetime%20Elision
|
[lifetime-elision]: #lifetime-elision
|
||||||
|
|
||||||
```rust,ignore
|
```rust,ignore
|
||||||
fn bar<'a>(...)
|
fn bar<'a>(...)
|
||||||
|
|
|
@ -430,7 +430,7 @@ Even when Rust code contains un-expanded macros, it can be parsed as a full
|
||||||
tools that process code. It also has a few consequences for the design of
|
tools that process code. It also has a few consequences for the design of
|
||||||
Rust’s macro system.
|
Rust’s macro system.
|
||||||
|
|
||||||
[ast]: glossary.html#Abstract%20Syntax%20Tree
|
[ast]: glossary.html#abstract-syntax-tree
|
||||||
|
|
||||||
One consequence is that Rust must determine, when it parses a macro invocation,
|
One consequence is that Rust must determine, when it parses a macro invocation,
|
||||||
whether the macro stands in for
|
whether the macro stands in for
|
||||||
|
|
|
@ -89,7 +89,7 @@ philosophy, memory safety, and the mechanism by which Rust guarantees it, the
|
||||||
> * exactly one mutable reference (`&mut T`).
|
> * exactly one mutable reference (`&mut T`).
|
||||||
|
|
||||||
[ownership]: ownership.html
|
[ownership]: ownership.html
|
||||||
[borrowing]: references-and-borrowing.html#Borrowing
|
[borrowing]: references-and-borrowing.html#borrowing
|
||||||
|
|
||||||
So, that’s the real definition of ‘immutability’: is this safe to have two
|
So, that’s the real definition of ‘immutability’: is this safe to have two
|
||||||
pointers to? In `Arc<T>`’s case, yes: the mutation is entirely contained inside
|
pointers to? In `Arc<T>`’s case, yes: the mutation is entirely contained inside
|
||||||
|
|
|
@ -65,10 +65,10 @@ elements onto them.
|
||||||
Vectors have a [generic type][generics] `Vec<T>`, so in this example `v` will have type
|
Vectors have a [generic type][generics] `Vec<T>`, so in this example `v` will have type
|
||||||
`Vec<i32>`. We'll cover [generics] in detail in a later chapter.
|
`Vec<i32>`. We'll cover [generics] in detail in a later chapter.
|
||||||
|
|
||||||
[arrays]: primitive-types.html#Arrays
|
[arrays]: primitive-types.html#arrays
|
||||||
[vectors]: vectors.html
|
[vectors]: vectors.html
|
||||||
[heap]: the-stack-and-the-heap.html#The%20Heap
|
[heap]: the-stack-and-the-heap.html#the-heap
|
||||||
[stack]: the-stack-and-the-heap.html#The%20Stack
|
[stack]: the-stack-and-the-heap.html#the-stack
|
||||||
[bindings]: variable-bindings.html
|
[bindings]: variable-bindings.html
|
||||||
[generics]: generics.html
|
[generics]: generics.html
|
||||||
|
|
||||||
|
@ -136,7 +136,7 @@ Rust allocates memory for an integer [i32] on the [stack][sh], copies the bit
|
||||||
pattern representing the value of 10 to the allocated memory and binds the
|
pattern representing the value of 10 to the allocated memory and binds the
|
||||||
variable name x to this memory region for future reference.
|
variable name x to this memory region for future reference.
|
||||||
|
|
||||||
[i32]: primitive-types.html#Numeric%20types
|
[i32]: primitive-types.html#numeric-types
|
||||||
|
|
||||||
Now consider the following code fragment:
|
Now consider the following code fragment:
|
||||||
|
|
||||||
|
|
|
@ -232,7 +232,7 @@ soon.
|
||||||
You can assign one tuple into another, if they have the same contained types
|
You can assign one tuple into another, if they have the same contained types
|
||||||
and [arity]. Tuples have the same arity when they have the same length.
|
and [arity]. Tuples have the same arity when they have the same length.
|
||||||
|
|
||||||
[arity]: glossary.html#Arity
|
[arity]: glossary.html#arity
|
||||||
|
|
||||||
```rust
|
```rust
|
||||||
let mut x = (1, 2); // x: (i32, i32)
|
let mut x = (1, 2); // x: (i32, i32)
|
||||||
|
|
|
@ -196,18 +196,18 @@
|
||||||
[Associated Types]: associated-types.html
|
[Associated Types]: associated-types.html
|
||||||
[Attributes]: attributes.html
|
[Attributes]: attributes.html
|
||||||
[Casting Between Types (`as`)]: casting-between-types.html#as
|
[Casting Between Types (`as`)]: casting-between-types.html#as
|
||||||
[Closures (`move` closures)]: closures.html#move%20closures
|
[Closures (`move` closures)]: closures.html#move-closures
|
||||||
[Closures]: closures.html
|
[Closures]: closures.html
|
||||||
[Comments]: comments.html
|
[Comments]: comments.html
|
||||||
[Crates and Modules (Defining Modules)]: crates-and-modules.html#Defining%20modules
|
[Crates and Modules (Defining Modules)]: crates-and-modules.html#defining-modules
|
||||||
[Crates and Modules (Exporting a Public Interface)]: crates-and-modules.html#Exporting%20a%20public%20interface
|
[Crates and Modules (Exporting a Public Interface)]: crates-and-modules.html#exporting-a-public-interface
|
||||||
[Crates and Modules (Importing External Crates)]: crates-and-modules.html#Importing%20external%20crates
|
[Crates and Modules (Importing External Crates)]: crates-and-modules.html#importing-external-crates
|
||||||
[Crates and Modules (Importing Modules with `use`)]: crates-and-modules.html#Importing%20modules%20with%20use
|
[Crates and Modules (Importing Modules with `use`)]: crates-and-modules.html#importing-modules-with-use
|
||||||
[Crates and Modules (Re-exporting with `pub use`)]: crates-and-modules.html#Re-exporting%20with%20pub%20use
|
[Crates and Modules (Re-exporting with `pub use`)]: crates-and-modules.html#re-exporting-with-pub-use
|
||||||
[Diverging Functions]: functions.html#Diverging%20functions
|
[Diverging Functions]: functions.html#diverging-functions
|
||||||
[Enums]: enums.html
|
[Enums]: enums.html
|
||||||
[Foreign Function Interface]: ffi.html
|
[Foreign Function Interface]: ffi.html
|
||||||
[Functions (Early Returns)]: functions.html#Early%20returns
|
[Functions (Early Returns)]: functions.html#early-returns
|
||||||
[Functions]: functions.html
|
[Functions]: functions.html
|
||||||
[Generics]: generics.html
|
[Generics]: generics.html
|
||||||
[Iterators]: iterators.html
|
[Iterators]: iterators.html
|
||||||
|
@ -216,24 +216,24 @@
|
||||||
[Loops (`for`)]: loops.html#for
|
[Loops (`for`)]: loops.html#for
|
||||||
[Loops (`loop`)]: loops.html#loop
|
[Loops (`loop`)]: loops.html#loop
|
||||||
[Loops (`while`)]: loops.html#while
|
[Loops (`while`)]: loops.html#while
|
||||||
[Loops (Ending Iteration Early)]: loops.html#Ending%20iteration%20early
|
[Loops (Ending Iteration Early)]: loops.html#ending-iteration-early
|
||||||
[Loops (Loops Labels)]: loops.html#Loop%20labels
|
[Loops (Loops Labels)]: loops.html#loop-labels
|
||||||
[Macros]: macros.html
|
[Macros]: macros.html
|
||||||
[Match]: match.html
|
[Match]: match.html
|
||||||
[Method Syntax (Method Calls)]: method-syntax.html#Method%20calls
|
[Method Syntax (Method Calls)]: method-syntax.html#method-calls
|
||||||
[Method Syntax]: method-syntax.html
|
[Method Syntax]: method-syntax.html
|
||||||
[Mutability]: mutability.html
|
[Mutability]: mutability.html
|
||||||
[Operators and Overloading]: operators-and-overloading.html
|
[Operators and Overloading]: operators-and-overloading.html
|
||||||
[Patterns (`ref` and `ref mut`)]: patterns.html#ref%20and%20ref%20mut
|
[Patterns (`ref` and `ref mut`)]: patterns.html#ref-and-ref-mut
|
||||||
[Patterns (Bindings)]: patterns.html#Bindings
|
[Patterns (Bindings)]: patterns.html#bindings
|
||||||
[Patterns (Ignoring bindings)]: patterns.html#Ignoring%20bindings
|
[Patterns (Ignoring bindings)]: patterns.html#ignoring-bindings
|
||||||
[Patterns (Multiple patterns)]: patterns.html#Multiple%20patterns
|
[Patterns (Multiple patterns)]: patterns.html#multiple-patterns
|
||||||
[Patterns (Ranges)]: patterns.html#Ranges
|
[Patterns (Ranges)]: patterns.html#ranges
|
||||||
[Primitive Types (`char`)]: primitive-types.html#char
|
[Primitive Types (`char`)]: primitive-types.html#char
|
||||||
[Primitive Types (Arrays)]: primitive-types.html#Arrays
|
[Primitive Types (Arrays)]: primitive-types.html#arrays
|
||||||
[Primitive Types (Booleans)]: primitive-types.html#Booleans
|
[Primitive Types (Booleans)]: primitive-types.html#booleans
|
||||||
[Primitive Types (Tuple Indexing)]: primitive-types.html#Tuple%20indexing
|
[Primitive Types (Tuple Indexing)]: primitive-types.html#tuple-indexing
|
||||||
[Primitive Types (Tuples)]: primitive-types.html#Tuples
|
[Primitive Types (Tuples)]: primitive-types.html#tuples
|
||||||
[Raw Pointers]: raw-pointers.html
|
[Raw Pointers]: raw-pointers.html
|
||||||
[Reference (Byte String Literals)]: ../reference.html#byte-string-literals
|
[Reference (Byte String Literals)]: ../reference.html#byte-string-literals
|
||||||
[Reference (Integer literals)]: ../reference.html#integer-literals
|
[Reference (Integer literals)]: ../reference.html#integer-literals
|
||||||
|
@ -241,13 +241,13 @@
|
||||||
[Reference (Raw String Literals)]: ../reference.html#raw-string-literals
|
[Reference (Raw String Literals)]: ../reference.html#raw-string-literals
|
||||||
[References and Borrowing]: references-and-borrowing.html
|
[References and Borrowing]: references-and-borrowing.html
|
||||||
[Strings]: strings.html
|
[Strings]: strings.html
|
||||||
[Structs (Update syntax)]: structs.html#Update%20syntax
|
[Structs (Update syntax)]: structs.html#update-syntax
|
||||||
[Structs]: structs.html
|
[Structs]: structs.html
|
||||||
[Traits (`where` clause)]: traits.html#Where%20clause
|
[Traits (`where` clause)]: traits.html#where-clause
|
||||||
[Traits (Multiple Trait Bounds)]: traits.html#Multiple%20trait%20bounds
|
[Traits (Multiple Trait Bounds)]: traits.html#multiple-trait-bounds
|
||||||
[Traits]: traits.html
|
[Traits]: traits.html
|
||||||
[Universal Function Call Syntax]: ufcs.html
|
[Universal Function Call Syntax]: ufcs.html
|
||||||
[Universal Function Call Syntax (Angle-bracket Form)]: ufcs.html#Angle-bracket%20Form
|
[Universal Function Call Syntax (Angle-bracket Form)]: ufcs.html#angle-bracket-form
|
||||||
[Unsafe]: unsafe.html
|
[Unsafe]: unsafe.html
|
||||||
[Unsized Types (`?Sized`)]: unsized-types.html#Sized
|
[Unsized Types (`?Sized`)]: unsized-types.html#sized
|
||||||
[Variable Bindings]: variable-bindings.html
|
[Variable Bindings]: variable-bindings.html
|
||||||
|
|
|
@ -81,7 +81,7 @@ Traits are useful because they allow a type to make certain promises about its
|
||||||
behavior. Generic functions can exploit this to constrain, or [bound][bounds], the types they
|
behavior. Generic functions can exploit this to constrain, or [bound][bounds], the types they
|
||||||
accept. Consider this function, which does not compile:
|
accept. Consider this function, which does not compile:
|
||||||
|
|
||||||
[bounds]: glossary.html#Bounds
|
[bounds]: glossary.html#bounds
|
||||||
|
|
||||||
```rust,ignore
|
```rust,ignore
|
||||||
fn print_area<T>(shape: T) {
|
fn print_area<T>(shape: T) {
|
||||||
|
|
|
@ -55,7 +55,7 @@ if x == y {
|
||||||
This compiles without error. Values of a `Num` type are the same as a value of
|
This compiles without error. Values of a `Num` type are the same as a value of
|
||||||
type `i32`, in every way. You can use [tuple struct] to really get a new type.
|
type `i32`, in every way. You can use [tuple struct] to really get a new type.
|
||||||
|
|
||||||
[tuple struct]: structs.html#Tuple%20structs
|
[tuple struct]: structs.html#tuple-structs
|
||||||
|
|
||||||
You can also use type aliases with generics:
|
You can also use type aliases with generics:
|
||||||
|
|
||||||
|
|
|
@ -151,6 +151,6 @@ API documentation][vec].
|
||||||
[vec]: ../std/vec/index.html
|
[vec]: ../std/vec/index.html
|
||||||
[box]: ../std/boxed/index.html
|
[box]: ../std/boxed/index.html
|
||||||
[generic]: generics.html
|
[generic]: generics.html
|
||||||
[panic]: concurrency.html#Panics
|
[panic]: concurrency.html#panics
|
||||||
[get]: ../std/vec/struct.Vec.html#method.get
|
[get]: ../std/vec/struct.Vec.html#method.get
|
||||||
[get_mut]: ../std/vec/struct.Vec.html#method.get_mut
|
[get_mut]: ../std/vec/struct.Vec.html#method.get_mut
|
||||||
|
|
|
@ -78,4 +78,4 @@ TODO: other common problems? SEME regions stuff, mostly?
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
[ex2]: lifetimes.html#Example%3A%20aliasing%20a%20mutable%20reference
|
[ex2]: lifetimes.html#example-aliasing-a-mutable-reference
|
||||||
|
|
|
@ -151,4 +151,4 @@ use fairly elaborate algorithms to cache bits throughout nested types with
|
||||||
special constrained representations. As such it is *especially* desirable that
|
special constrained representations. As such it is *especially* desirable that
|
||||||
we leave enum layout unspecified today.
|
we leave enum layout unspecified today.
|
||||||
|
|
||||||
[dst]: exotic-sizes.html#Dynamically%20Sized%20Types%20(DSTs)
|
[dst]: exotic-sizes.html#dynamically-sized-types-dsts
|
||||||
|
|
|
@ -2108,7 +2108,7 @@ On `struct`s:
|
||||||
list of names `#[macro_use(foo, bar)]` restricts the import to just those
|
list of names `#[macro_use(foo, bar)]` restricts the import to just those
|
||||||
macros named. The `extern crate` must appear at the crate root, not inside
|
macros named. The `extern crate` must appear at the crate root, not inside
|
||||||
`mod`, which ensures proper function of the [`$crate` macro
|
`mod`, which ensures proper function of the [`$crate` macro
|
||||||
variable](book/macros.html#The%20variable%20%24crate).
|
variable](book/macros.html#the-variable-crate).
|
||||||
|
|
||||||
- `macro_reexport` on an `extern crate` — re-export the named macros.
|
- `macro_reexport` on an `extern crate` — re-export the named macros.
|
||||||
|
|
||||||
|
@ -2118,7 +2118,7 @@ On `struct`s:
|
||||||
link it into the output.
|
link it into the output.
|
||||||
|
|
||||||
See the [macros section of the
|
See the [macros section of the
|
||||||
book](book/macros.html#Scoping%20and%20macro%20import%2Fexport) for more information on
|
book](book/macros.html#scoping-and-macro-importexport) for more information on
|
||||||
macro scope.
|
macro scope.
|
||||||
|
|
||||||
|
|
||||||
|
@ -2277,7 +2277,7 @@ For any lint check `C`:
|
||||||
|
|
||||||
The lint checks supported by the compiler can be found via `rustc -W help`,
|
The lint checks supported by the compiler can be found via `rustc -W help`,
|
||||||
along with their default settings. [Compiler
|
along with their default settings. [Compiler
|
||||||
plugins](book/compiler-plugins.html#Lint%20plugins) can provide additional lint checks.
|
plugins](book/compiler-plugins.html#lint-plugins) can provide additional lint checks.
|
||||||
|
|
||||||
```{.ignore}
|
```{.ignore}
|
||||||
pub mod m1 {
|
pub mod m1 {
|
||||||
|
|
|
@ -102,7 +102,7 @@ const MAX_REFCOUNT: usize = (isize::MAX) as usize;
|
||||||
/// [downgrade]: struct.Arc.html#method.downgrade
|
/// [downgrade]: struct.Arc.html#method.downgrade
|
||||||
/// [upgrade]: struct.Weak.html#method.upgrade
|
/// [upgrade]: struct.Weak.html#method.upgrade
|
||||||
/// [`None`]: ../../std/option/enum.Option.html#variant.None
|
/// [`None`]: ../../std/option/enum.Option.html#variant.None
|
||||||
/// [assoc]: ../../book/method-syntax.html#Associated%20functions
|
/// [assoc]: ../../book/method-syntax.html#associated-functions
|
||||||
///
|
///
|
||||||
/// # Examples
|
/// # Examples
|
||||||
///
|
///
|
||||||
|
|
|
@ -215,7 +215,7 @@
|
||||||
//! [downgrade]: struct.Rc.html#method.downgrade
|
//! [downgrade]: struct.Rc.html#method.downgrade
|
||||||
//! [upgrade]: struct.Weak.html#method.upgrade
|
//! [upgrade]: struct.Weak.html#method.upgrade
|
||||||
//! [`None`]: ../../std/option/enum.Option.html#variant.None
|
//! [`None`]: ../../std/option/enum.Option.html#variant.None
|
||||||
//! [assoc]: ../../book/method-syntax.html#Associated%20functions
|
//! [assoc]: ../../book/method-syntax.html#associated-functions
|
||||||
//! [mutability]: ../../std/cell/index.html#introducing-mutability-inside-of-something-immutable
|
//! [mutability]: ../../std/cell/index.html#introducing-mutability-inside-of-something-immutable
|
||||||
|
|
||||||
#![stable(feature = "rust1", since = "1.0.0")]
|
#![stable(feature = "rust1", since = "1.0.0")]
|
||||||
|
|
|
@ -525,7 +525,7 @@ pub fn replace<T>(dest: &mut T, mut src: T) -> T {
|
||||||
/// it will not release any borrows, as borrows are based on lexical scope.
|
/// it will not release any borrows, as borrows are based on lexical scope.
|
||||||
///
|
///
|
||||||
/// This effectively does nothing for
|
/// This effectively does nothing for
|
||||||
/// [types which implement `Copy`](../../book/ownership.html#Copy%20types),
|
/// [types which implement `Copy`](../../book/ownership.html#copy-types),
|
||||||
/// e.g. integers. Such values are copied and _then_ moved into the function,
|
/// e.g. integers. Such values are copied and _then_ moved into the function,
|
||||||
/// so the value persists after this function call.
|
/// so the value persists after this function call.
|
||||||
///
|
///
|
||||||
|
|
|
@ -25,7 +25,7 @@
|
||||||
/// Book][moreinfo] contains more details about the precise nature of
|
/// Book][moreinfo] contains more details about the precise nature of
|
||||||
/// these internals.
|
/// these internals.
|
||||||
///
|
///
|
||||||
/// [moreinfo]: ../../book/trait-objects.html#Representation
|
/// [moreinfo]: ../../book/trait-objects.html#representation
|
||||||
///
|
///
|
||||||
/// `TraitObject` is guaranteed to match layouts, but it is not the
|
/// `TraitObject` is guaranteed to match layouts, but it is not the
|
||||||
/// type of trait objects (e.g. the fields are not directly accessible
|
/// type of trait objects (e.g. the fields are not directly accessible
|
||||||
|
|
|
@ -189,8 +189,8 @@
|
||||||
//! [`sync`]: sync/index.html
|
//! [`sync`]: sync/index.html
|
||||||
//! [`thread`]: thread/index.html
|
//! [`thread`]: thread/index.html
|
||||||
//! [`use std::env`]: env/index.html
|
//! [`use std::env`]: env/index.html
|
||||||
//! [`use`]: ../book/crates-and-modules.html#Importing%20Modules%20with%20use
|
//! [`use`]: ../book/crates-and-modules.html#importing-modules-with-use
|
||||||
//! [crate root]: ../book/crates-and-modules.html#Basic%20terminology%3A%20Crates%20and%20Modules
|
//! [crate root]: ../book/crates-and-modules.html#basic-terminology-crates-and-modules
|
||||||
//! [crates.io]: https://crates.io
|
//! [crates.io]: https://crates.io
|
||||||
//! [deref coercions]: ../book/deref-coercions.html
|
//! [deref coercions]: ../book/deref-coercions.html
|
||||||
//! [files]: fs/struct.File.html
|
//! [files]: fs/struct.File.html
|
||||||
|
|
|
@ -490,7 +490,7 @@ mod prim_str { }
|
||||||
/// assert_eq!(tuple.2, 'c');
|
/// assert_eq!(tuple.2, 'c');
|
||||||
/// ```
|
/// ```
|
||||||
///
|
///
|
||||||
/// For more about tuples, see [the book](../book/primitive-types.html#Tuples).
|
/// For more about tuples, see [the book](../book/primitive-types.html#tuples).
|
||||||
///
|
///
|
||||||
/// # Trait implementations
|
/// # Trait implementations
|
||||||
///
|
///
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue