Skip to content

Commit 3574e72

Browse files
committed
---
yaml --- r: 225711 b: refs/heads/stable c: 7d9427e h: refs/heads/master i: 225709: c82b944 225707: 5756e84 225703: 9a3be8a 225695: 667f3c2 v: v3
1 parent 060a45b commit 3574e72

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+2486
-821
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,6 @@ refs/heads/tmp: e5d90d98402475b6e154ce216f9efcb80da1a747
2929
refs/tags/1.0.0-alpha.2: 4c705f6bc559886632d3871b04f58aab093bfa2f
3030
refs/tags/homu-tmp: 1fe32ca12c51afcd761d9962f51a74ff0d07a591
3131
refs/tags/1.0.0-beta: 8cbb92b53468ee2b0c2d3eeb8567005953d40828
32-
refs/heads/stable: 2c75256c151774407e5f4a0e4c655604d34bee17
32+
refs/heads/stable: 7d9427e6cd798e24b4be633aa4bf459bd232400c
3333
refs/tags/1.0.0: 55bd4f8ff2b323f317ae89e254ce87162d52a375
3434
refs/tags/1.1.0: bc3c16f09287e5545c1d3f76b7abd54f2eca868b

branches/stable/mk/cfg/x86_64-pc-windows-msvc.mk

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ CFG_STATIC_LIB_NAME_x86_64-pc-windows-msvc=$(1).lib
99
CFG_LIB_GLOB_x86_64-pc-windows-msvc=$(1)-*.dll
1010
CFG_LIB_DSYM_GLOB_x86_64-pc-windows-msvc=$(1)-*.dylib.dSYM
1111
CFG_JEMALLOC_CFLAGS_x86_64-pc-windows-msvc :=
12-
CFG_GCCISH_CFLAGS_x86_64-pc-windows-msvc :=
13-
CFG_GCCISH_CXXFLAGS_x86_64-pc-windows-msvc :=
12+
CFG_GCCISH_CFLAGS_x86_64-pc-windows-msvc := -MD
13+
CFG_GCCISH_CXXFLAGS_x86_64-pc-windows-msvc := -MD
1414
CFG_GCCISH_LINK_FLAGS_x86_64-pc-windows-msvc :=
1515
CFG_GCCISH_DEF_FLAG_x86_64-pc-windows-msvc :=
1616
CFG_LLC_FLAGS_x86_64-pc-windows-msvc :=

branches/stable/mk/docs.mk

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,7 @@ DOC_TARGETS += doc/not_found.html
169169
doc/not_found.html: $(D)/not_found.md $(HTML_DEPS) | doc/
170170
@$(call E, rustdoc: $@)
171171
$(Q)$(RUSTDOC) $(RUSTDOC_HTML_OPTS_NO_CSS) \
172+
--markdown-no-toc \
172173
--markdown-css http://doc.rust-lang.org/rust.css $<
173174

174175
define DEF_DOC

branches/stable/src/doc/grammar.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,8 @@ type_path_tail : '<' type_expr [ ',' type_expr ] + '>'
281281
## Macros
282282

283283
```antlr
284-
expr_macro_rules : "macro_rules" '!' ident '(' macro_rule * ')' ;
284+
expr_macro_rules : "macro_rules" '!' ident '(' macro_rule * ')' ';'
285+
| "macro_rules" '!' ident '{' macro_rule * '}' ;
285286
macro_rule : '(' matcher * ')' "=>" '(' transcriber * ')' ';' ;
286287
matcher : '(' matcher * ')' | '[' matcher * ']'
287288
| '{' matcher * '}' | '$' ident ':' ident

branches/stable/src/doc/not_found.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,20 +11,20 @@ Looks like you've taken a wrong turn.
1111

1212
Some things that might be helpful to you though:
1313

14-
## Search
14+
# Search
1515

1616
* <form action="https://duckduckgo.com/">
1717
<input type="text" id="site-search" name="q" size="80"></input>
1818
<input type="submit" value="Search DuckDuckGo">
1919
</form>
2020
* Rust doc search: <span id="core-search"></span>
2121

22-
## Reference
22+
# Reference
2323

2424
* [The Rust official site](http://rust-lang.org)
2525
* [The Rust reference](http://doc.rust-lang.org/reference.html)
2626

27-
## Docs
27+
# Docs
2828

2929
* [The standard library](http://doc.rust-lang.org/std/)
3030

branches/stable/src/doc/reference.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1367,7 +1367,6 @@ Traits can include default implementations of methods, as in:
13671367
```
13681368
trait Foo {
13691369
fn bar(&self);
1370-
13711370
fn baz(&self) { println!("We called baz."); }
13721371
}
13731372
```

branches/stable/src/doc/trpl/const-and-static.md

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,10 @@ unsafe {
6464

6565
[unsafe]: unsafe.html
6666

67-
Furthermore, any type stored in a `static` must be `Sync`.
67+
Furthermore, any type stored in a `static` must be `Sync`, and may not have
68+
a [`Drop`][drop] implementation.
69+
70+
[drop]: drop.html
6871

6972
# Initializing
7073

@@ -78,7 +81,3 @@ Almost always, if you can choose between the two, choose `const`. It’s pretty
7881
rare that you actually want a memory location associated with your constant,
7982
and using a const allows for optimizations like constant propagation not only
8083
in your crate but downstream crates.
81-
82-
A const can be thought of as a `#define` in C: it has metadata overhead but it
83-
has no runtime overhead. “Should I use a #define or a static in C,” is largely
84-
the same question as whether you should use a const or a static in Rust.

branches/stable/src/doc/trpl/dining-philosophers.md

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -674,9 +674,13 @@ let handles: Vec<_> = philosophers.into_iter().map(|p| {
674674

675675
Finally, inside of our `map()`/`collect()` loop, we call `table.clone()`. The
676676
`clone()` method on `Arc<T>` is what bumps up the reference count, and when it
677-
goes out of scope, it decrements the count. You’ll notice we can introduce a
678-
new binding to `table` here, and it will shadow the old one. This is often used
679-
so that you don’t need to come up with two unique names.
677+
goes out of scope, it decrements the count. This is needed so that we know how
678+
many references to `table` exist across our threads. If we didn’t have a count,
679+
we wouldn’t know how to deallocate it.
680+
681+
You’ll notice we can introduce a new binding to `table` here, and it will
682+
shadow the old one. This is often used so that you don’t need to come up with
683+
two unique names.
680684

681685
With this, our program works! Only two philosophers can eat at any one time,
682686
and so you’ll get some output like this:

branches/stable/src/doc/trpl/enums.md

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,3 +64,45 @@ equality yet, but we’ll find out in the [`traits`][traits] section.
6464
[match]: match.html
6565
[if-let]: if-let.html
6666
[traits]: traits.html
67+
68+
# Constructors as functions
69+
70+
An enum’s constructors can also be used like functions. For example:
71+
72+
```rust
73+
# enum Message {
74+
# Write(String),
75+
# }
76+
let m = Message::Write("Hello, world".to_string());
77+
```
78+
79+
Is the same as
80+
81+
```rust
82+
# enum Message {
83+
# Write(String),
84+
# }
85+
fn foo(x: String) -> Message {
86+
Message::Write(x)
87+
}
88+
89+
let x = foo("Hello, world".to_string());
90+
```
91+
92+
This is not immediately useful to us, but when we get to
93+
[`closures`][closures], we’ll talk about passing functions as arguments to
94+
other functions. For example, with [`iterators`][iterators], we can do this
95+
to convert a vector of `String`s into a vector of `Message::Write`s:
96+
97+
```rust
98+
# enum Message {
99+
# Write(String),
100+
# }
101+
102+
let v = vec!["Hello".to_string(), "World".to_string()];
103+
104+
let v1: Vec<Message> = v.into_iter().map(Message::Write).collect();
105+
```
106+
107+
[closures]: closures.html
108+
[iterators]: iterators.html

branches/stable/src/doc/trpl/ffi.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -342,8 +342,10 @@ Note that frameworks are only available on OSX targets.
342342
The different `kind` values are meant to differentiate how the native library
343343
participates in linkage. From a linkage perspective, the rust compiler creates
344344
two flavors of artifacts: partial (rlib/staticlib) and final (dylib/binary).
345-
Native dynamic libraries and frameworks are propagated to the final artifact
346-
boundary, while static libraries are not propagated at all.
345+
Native dynamic library and framework dependencies are propagated to the final
346+
artifact boundary, while static library dependencies are not propagated at
347+
all, because the static libraries are integrated directly into the subsequent
348+
artifact.
347349
348350
A few examples of how this model can be used are:
349351

branches/stable/src/doc/trpl/method-syntax.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,8 +86,8 @@ impl Circle {
8686
# Chaining method calls
8787

8888
So, now we know how to call a method, such as `foo.bar()`. But what about our
89-
original example, `foo.bar().baz()`? This is called ‘method chaining’, and we
90-
can do it by returning `self`.
89+
original example, `foo.bar().baz()`? This is called ‘method chaining’. Let’s
90+
look at an example:
9191

9292
```rust
9393
struct Circle {

branches/stable/src/doc/trpl/patterns.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,31 @@ match x {
154154

155155
This prints `Got an int!`.
156156

157+
If you’re using `if` with multiple patterns, the `if` applies to both sides:
158+
159+
```rust
160+
let x = 4;
161+
let y = false;
162+
163+
match x {
164+
4 | 5 if y => println!("yes"),
165+
_ => println!("no"),
166+
}
167+
```
168+
169+
This prints `no`, because the `if` applies to the whole of `4 | 5`, and not to
170+
just the `5`, In other words, the the precedence of `if` behaves like this:
171+
172+
```text
173+
(4 | 5) if y => ...
174+
```
175+
176+
not this:
177+
178+
```text
179+
4 | (5 if y) => ...
180+
```
181+
157182
# ref and ref mut
158183

159184
If you want to get a [reference][ref], use the `ref` keyword:

branches/stable/src/doc/trpl/references-and-borrowing.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -151,9 +151,9 @@ As it turns out, there are rules.
151151

152152
Here’s the rules about borrowing in Rust:
153153

154-
First, any borrow must last for a smaller scope than the owner. Second, you may
155-
have one or the other of these two kinds of borrows, but not both at the same
156-
time:
154+
First, any borrow must last for a scope no greater than that of the owner.
155+
Second, you may have one or the other of these two kinds of borrows, but not
156+
both at the same time:
157157

158158
* one or more references (`&T`) to a resource.
159159
* exactly one mutable reference (`&mut T`)

branches/stable/src/doc/trpl/strings.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,30 @@ let dog = hachiko.chars().nth(1); // kinda like hachiko[1]
117117

118118
This emphasizes that we have to go through the whole list of `chars`.
119119

120+
## Slicing
121+
122+
You can get a slice of a string with slicing syntax:
123+
124+
```rust
125+
let dog = "hachiko";
126+
let hachi = &dog[0..5];
127+
```
128+
129+
But note that these are _byte_ offsets, not _character_ offsets. So
130+
this will fail at runtime:
131+
132+
```rust,should_panic
133+
let dog = "忠犬ハチ公";
134+
let hachi = &dog[0..2];
135+
```
136+
137+
with this error:
138+
139+
```text
140+
thread '<main>' panicked at 'index 0 and/or 2 in `忠犬ハチ公` do not lie on
141+
character boundary'
142+
```
143+
120144
## Concatenation
121145

122146
If you have a `String`, you can concatenate a `&str` to the end of it:

0 commit comments

Comments
 (0)