Skip to content

Commit 5c674a1

Browse files
authored
Auto merge of #34695 - steveklabnik:rollup, r=steveklabnik
Rollup of 15 pull requests - Successful merges: #33250, #33265, #34277, #34327, #34521, #34558, #34615, #34619, #34621, #34625, #34626, #34636, #34664, #34667, #34685 - Failed merges: #33951
2 parents 801d268 + 2262d73 commit 5c674a1

File tree

23 files changed

+183
-131
lines changed

23 files changed

+183
-131
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ build.
6666
6767
[MSYS2][msys2] can be used to easily build Rust on Windows:
6868
69-
msys2: https://msys2.github.io/
69+
[msys2]: https://msys2.github.io/
7070
7171
1. Grab the latest [MSYS2 installer][msys2] and go through the installer.
7272

mk/main.mk

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
######################################################################
1414

1515
# The version number
16-
CFG_RELEASE_NUM=1.11.0
16+
CFG_RELEASE_NUM=1.12.0
1717

1818
# An optional number to put after the label, e.g. '.2' -> '-beta.2'
1919
# NB Make sure it starts with a dot to conform to semver pre-release

src/bootstrap/bootstrap.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -359,7 +359,7 @@ def main():
359359
parser.add_argument('--clean', action='store_true')
360360
parser.add_argument('-v', '--verbose', action='store_true')
361361

362-
args = [a for a in sys.argv if a != '-h']
362+
args = [a for a in sys.argv if a != '-h' and a != '--help']
363363
args, _ = parser.parse_known_args(args)
364364

365365
# Configure initial bootstrap

src/doc/book/closures.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -339,7 +339,7 @@ fn call_with_ref<'a, F>(some_closure:F) -> i32
339339
where F: Fn(&'a 32) -> i32 {
340340
```
341341

342-
However this presents a problem with in our case. When you specify the explict
342+
However this presents a problem with in our case. When you specify the explicit
343343
lifetime on a function it binds that lifetime to the *entire* scope of the function
344344
instead of just the invocation scope of our closure. This means that the borrow checker
345345
will see a mutable reference in the same lifetime as our immutable reference and fail
@@ -354,7 +354,7 @@ fn call_with_ref<F>(some_closure:F) -> i32
354354
```
355355

356356
This lets the Rust compiler find the minimum lifetime to invoke our closure and
357-
satisfy the borrow checker's rules. Our function then compiles and excutes as we
357+
satisfy the borrow checker's rules. Our function then compiles and executes as we
358358
expect.
359359

360360
```rust

src/doc/book/documentation.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -486,6 +486,17 @@ you have a module in `foo.rs`, you'll often open its code and see this:
486486
//! The `foo` module contains a lot of useful functionality blah blah blah
487487
```
488488

489+
### Crate documentation
490+
491+
Crates can be documented by placing an inner doc comment (`//!`) at the
492+
beginning of the crate root, aka `lib.rs`:
493+
494+
```rust
495+
//! This is documentation for the `foo` crate.
496+
//!
497+
//! The foo crate is meant to be used for bar.
498+
```
499+
489500
### Documentation comment style
490501

491502
Check out [RFC 505][rfc505] for full conventions around the style and format of

src/doc/book/guessing-game.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -370,7 +370,7 @@ We could also use a range of versions.
370370
[Cargo’s documentation][cargodoc] contains more details.
371371

372372
[semver]: http://semver.org
373-
[cargodoc]: http://doc.crates.io/crates-io.html
373+
[cargodoc]: http://doc.crates.io/specifying-dependencies.html
374374

375375
Now, without changing any of our code, let’s build our project:
376376

src/doc/book/loops.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ When you need to keep track of how many times you already looped, you can use th
105105
#### On ranges:
106106

107107
```rust
108-
for (i,j) in (5..10).enumerate() {
108+
for (i, j) in (5..10).enumerate() {
109109
println!("i = {} and j = {}", i, j);
110110
}
111111
```

src/doc/book/mutability.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,8 @@ Note that here, the `x` is mutable, but not the `y`.
6262
# Interior vs. Exterior Mutability
6363

6464
However, when we say something is ‘immutable’ in Rust, that doesn’t mean that
65-
it’s not able to be changed: we mean something has ‘exterior mutability’. Consider,
66-
for example, [`Arc<T>`][arc]:
65+
it’s not able to be changed: we are referring to its ‘exterior mutability’ that
66+
in this case is immutable. Consider, for example, [`Arc<T>`][arc]:
6767

6868
```rust
6969
use std::sync::Arc;

src/doc/book/structs.md

Lines changed: 50 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -163,11 +163,51 @@ struct Point(i32, i32, i32);
163163
let black = Color(0, 0, 0);
164164
let origin = Point(0, 0, 0);
165165
```
166-
Here, `black` and `origin` are not equal, even though they contain the same
167-
values.
168166

169-
It is almost always better to use a `struct` than a tuple struct. We
170-
would write `Color` and `Point` like this instead:
167+
Here, `black` and `origin` are not the same type, even though they contain the
168+
same values.
169+
170+
The members of a tuple struct may be accessed by dot notation or destructuring
171+
`let`, just like regular tuples:
172+
173+
```rust
174+
# struct Color(i32, i32, i32);
175+
# struct Point(i32, i32, i32);
176+
# let black = Color(0, 0, 0);
177+
# let origin = Point(0, 0, 0);
178+
let black_r = black.0;
179+
let Point(_, origin_y, origin_z) = origin;
180+
```
181+
182+
Patterns like `Point(_, origin_y, origin_z)` are also used in
183+
[match expressions][match].
184+
185+
One case when a tuple struct is very useful is when it has only one element.
186+
We call this the ‘newtype’ pattern, because it allows you to create a new type
187+
that is distinct from its contained value and also expresses its own semantic
188+
meaning:
189+
190+
```rust
191+
struct Inches(i32);
192+
193+
let length = Inches(10);
194+
195+
let Inches(integer_length) = length;
196+
println!("length is {} inches", integer_length);
197+
```
198+
199+
As above, you can extract the inner integer type through a destructuring `let`.
200+
In this case, the `let Inches(integer_length)` assigns `10` to `integer_length`.
201+
We could have used dot notation to do the same thing:
202+
203+
```rust
204+
# struct Inches(i32);
205+
# let length = Inches(10);
206+
let integer_length = length.0;
207+
```
208+
209+
It's always possible to use a `struct` instead of a tuple struct, and can be
210+
clearer. We could write `Color` and `Point` like this instead:
171211

172212
```rust
173213
struct Color {
@@ -187,32 +227,19 @@ Good names are important, and while values in a tuple struct can be
187227
referenced with dot notation as well, a `struct` gives us actual names,
188228
rather than positions.
189229

190-
There _is_ one case when a tuple struct is very useful, though, and that is when
191-
it has only one element. We call this the ‘newtype’ pattern, because
192-
it allows you to create a new type that is distinct from its contained value
193-
and also expresses its own semantic meaning:
194-
195-
```rust
196-
struct Inches(i32);
197-
198-
let length = Inches(10);
199-
200-
let Inches(integer_length) = length;
201-
println!("length is {} inches", integer_length);
202-
```
203-
204-
As you can see here, you can extract the inner integer type through a
205-
destructuring `let`, as with regular tuples. In this case, the
206-
`let Inches(integer_length)` assigns `10` to `integer_length`.
230+
[match]: match.html
207231

208232
# Unit-like structs
209233

210234
You can define a `struct` with no members at all:
211235

212236
```rust
213-
struct Electron;
237+
struct Electron {} // use empty braces...
238+
struct Proton; // ...or just a semicolon
214239

215-
let x = Electron;
240+
// whether you declared the struct with braces or not, do the same when creating one
241+
let x = Electron {};
242+
let y = Proton;
216243
```
217244

218245
Such a `struct` is called ‘unit-like’ because it resembles the empty

src/doc/book/testing.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -431,7 +431,7 @@ one.
431431

432432
Cargo will ignore files in subdirectories of the `tests/` directory.
433433
Therefore shared modules in integrations tests are possible.
434-
For example `tests/common/mod.rs` is not seperatly compiled by cargo but can
434+
For example `tests/common/mod.rs` is not separately compiled by cargo but can
435435
be imported in every test with `mod common;`
436436

437437
That's all there is to the `tests` directory. The `tests` module isn't needed

0 commit comments

Comments
 (0)