Skip to content

Commit a535a9b

Browse files
committed
---
yaml --- r: 194254 b: refs/heads/tmp c: 2625bf9 h: refs/heads/master v: v3
1 parent 58483a5 commit a535a9b

File tree

39 files changed

+385
-791
lines changed

39 files changed

+385
-791
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ refs/heads/building: 126db549b038c84269a1e4fe46f051b2c15d6970
3434
refs/heads/beta: a3b13610c5b93d9ada072471a001a5613df6a960
3535
refs/heads/windistfix: 7608dbad651f02e837ed05eef3d74a6662a6e928
3636
refs/tags/1.0.0-alpha: e42bd6d93a1d3433c486200587f8f9e12590a4d7
37-
refs/heads/tmp: 67e516c5c2ddd0dbed6b07ccca6b5bdd4ad10b36
37+
refs/heads/tmp: 2625bf9ae4a46000ae3a138f938f8f1dd3c095a8
3838
refs/tags/1.0.0-alpha.2: 4c705f6bc559886632d3871b04f58aab093bfa2f
3939
refs/tags/homu-tmp: 28a0b25f424090255966273994748a9f9901059f
4040
refs/heads/gate: 97c84447b65164731087ea82685580cc81424412

branches/tmp/man/rustc.1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,7 @@ full debug info with variable and type information.
242242
\fBopt\-level\fR=\fIVAL\fR
243243
Optimize with possible levels 0\[en]3
244244

245-
.SH ENVIRONMENT
245+
.SH ENVIRONMENT VARIABLES
246246

247247
Some of these affect the output of the compiler, while others affect programs
248248
which link to the standard library.

branches/tmp/src/doc/reference.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1982,7 +1982,7 @@ the namespace hierarchy as it normally would.
19821982
## Attributes
19831983

19841984
```{.ebnf .gram}
1985-
attribute : '#' '!' ? '[' meta_item ']' ;
1985+
attribute : "#!" ? '[' meta_item ']' ;
19861986
meta_item : ident [ '=' literal
19871987
| '(' meta_seq ')' ] ? ;
19881988
meta_seq : meta_item [ ',' meta_seq ] ? ;
@@ -3158,7 +3158,7 @@ ten_times(|j| println!("hello, {}", j));
31583158
### While loops
31593159

31603160
```{.ebnf .gram}
3161-
while_expr : [ lifetime ':' ] "while" no_struct_literal_expr '{' block '}' ;
3161+
while_expr : "while" no_struct_literal_expr '{' block '}' ;
31623162
```
31633163

31643164
A `while` loop begins by evaluating the boolean loop conditional expression.
@@ -3223,7 +3223,7 @@ A `continue` expression is only permitted in the body of a loop.
32233223
### For expressions
32243224

32253225
```{.ebnf .gram}
3226-
for_expr : [ lifetime ':' ] "for" pat "in" no_struct_literal_expr '{' block '}' ;
3226+
for_expr : "for" pat "in" no_struct_literal_expr '{' block '}' ;
32273227
```
32283228

32293229
A `for` expression is a syntactic construct for looping over elements provided

branches/tmp/src/doc/trpl/SUMMARY.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Summary
22

3-
* [The Basics](basic.md)
3+
* [I: The Basics](basic.md)
44
* [Installing Rust](installing-rust.md)
55
* [Hello, world!](hello-world.md)
66
* [Hello, Cargo!](hello-cargo.md)
@@ -14,7 +14,7 @@
1414
* [Strings](strings.md)
1515
* [Arrays, Vectors, and Slices](arrays-vectors-and-slices.md)
1616
* [Standard Input](standard-input.md)
17-
* [Intermediate Rust](intermediate.md)
17+
* [II: Intermediate Rust](intermediate.md)
1818
* [Crates and Modules](crates-and-modules.md)
1919
* [Testing](testing.md)
2020
* [Pointers](pointers.md)
@@ -31,7 +31,7 @@
3131
* [Concurrency](concurrency.md)
3232
* [Error Handling](error-handling.md)
3333
* [Documentation](documentation.md)
34-
* [Advanced Topics](advanced.md)
34+
* [III: Advanced Topics](advanced.md)
3535
* [FFI](ffi.md)
3636
* [Unsafe Code](unsafe.md)
3737
* [Advanced Macros](advanced-macros.md)

branches/tmp/src/doc/trpl/compound-data-types.md

Lines changed: 33 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ This pattern is very powerful, and we'll see it repeated more later.
4747

4848
There are also a few things you can do with a tuple as a whole, without
4949
destructuring. You can assign one tuple into another, if they have the same
50-
contained types and [arity]. Tuples have the same arity when they have the same
50+
contained types and arity. Tuples have the same arity when they have the same
5151
length.
5252

5353
```rust
@@ -196,9 +196,8 @@ Now, we have actual names, rather than positions. Good names are important,
196196
and with a struct, we have actual names.
197197

198198
There _is_ one case when a tuple struct is very useful, though, and that's a
199-
tuple struct with only one element. We call this the *newtype* pattern, because
200-
it allows you to create a new type, distinct from that of its contained value
201-
and expressing its own semantic meaning:
199+
tuple struct with only one element. We call this a *newtype*, because it lets
200+
you create a new type that's similar to another one:
202201

203202
```{rust}
204203
struct Inches(i32);
@@ -217,7 +216,7 @@ destructuring `let`, as we discussed previously in 'tuples.' In this case, the
217216

218217
Finally, Rust has a "sum type", an *enum*. Enums are an incredibly useful
219218
feature of Rust, and are used throughout the standard library. An `enum` is
220-
a type which relates a set of alternates to a specific name. For example, below
219+
a type which ties a set of alternates to a specific name. For example, below
221220
we define `Character` to be either a `Digit` or something else. These
222221
can be used via their fully scoped names: `Character::Other` (more about `::`
223222
below).
@@ -229,8 +228,8 @@ enum Character {
229228
}
230229
```
231230

232-
Most normal types are allowed as the variant components of an `enum`. Here are
233-
some examples:
231+
An `enum` variant can be defined as most normal types. Below are some example
232+
types which also would be allowed in an `enum`.
234233

235234
```rust
236235
struct Empty;
@@ -240,15 +239,15 @@ struct Status { Health: i32, Mana: i32, Attack: i32, Defense: i32 }
240239
struct HeightDatabase(Vec<i32>);
241240
```
242241

243-
You see that, depending on its type, an `enum` variant may or may not hold data.
244-
In `Character`, for instance, `Digit` gives a meaningful name for an `i32`
245-
value, where `Other` is only a name. However, the fact that they represent
246-
distinct categories of `Character` is a very useful property.
242+
So you see that depending on the sub-datastructure, the `enum` variant, same as
243+
a struct, may or may not hold data. That is, in `Character`, `Digit` is a name
244+
tied to an `i32` where `Other` is just a name. However, the fact that they are
245+
distinct makes this very useful.
247246

248-
As with structures, the variants of an enum by default are not comparable with
249-
equality operators (`==`, `!=`), have no ordering (`<`, `>=`, etc.), and do not
250-
support other binary operations such as `*` and `+`. As such, the following code
251-
is invalid for the example `Character` type:
247+
As with structures, enums don't by default have access to operators such as
248+
compare ( `==` and `!=`), binary operations (`*` and `+`), and order
249+
(`<` and `>=`). As such, using the previous `Character` type, the
250+
following code is invalid:
252251

253252
```{rust,ignore}
254253
// These assignments both succeed
@@ -266,10 +265,9 @@ let four_equals_ten = four == ten;
266265
```
267266

268267
This may seem rather limiting, but it's a limitation which we can overcome.
269-
There are two ways: by implementing equality ourselves, or by pattern matching
270-
variants with [`match`][match] expressions, which you'll learn in the next
271-
chapter. We don't know enough about Rust to implement equality yet, but we can
272-
use the `Ordering` enum from the standard library, which does:
268+
There are two ways: by implementing equality ourselves, or by using the
269+
[`match`][match] keyword. We don't know enough about Rust to implement equality
270+
yet, but we can use the `Ordering` enum from the standard library, which does:
273271

274272
```
275273
enum Ordering {
@@ -279,8 +277,9 @@ enum Ordering {
279277
}
280278
```
281279

282-
Because `Ordering` has already been defined for us, we will import it with the
283-
`use` keyword. Here's an example of how it is used:
280+
Because we did not define `Ordering`, we must import it (from the std
281+
library) with the `use` keyword. Here's an example of how `Ordering` is
282+
used:
284283

285284
```{rust}
286285
use std::cmp::Ordering;
@@ -314,17 +313,17 @@ the standard library if you need them.
314313

315314
Okay, let's talk about the actual code in the example. `cmp` is a function that
316315
compares two things, and returns an `Ordering`. We return either
317-
`Ordering::Less`, `Ordering::Greater`, or `Ordering::Equal`, depending on
318-
whether the first value is less than, greater than, or equal to the second. Note
319-
that each variant of the `enum` is namespaced under the `enum` itself: it's
320-
`Ordering::Greater`, not `Greater`.
316+
`Ordering::Less`, `Ordering::Greater`, or `Ordering::Equal`, depending on if
317+
the two values are less, greater, or equal. Note that each variant of the
318+
`enum` is namespaced under the `enum` itself: it's `Ordering::Greater` not
319+
`Greater`.
321320

322321
The `ordering` variable has the type `Ordering`, and so contains one of the
323322
three values. We then do a bunch of `if`/`else` comparisons to check which
324323
one it is.
325324

326-
This `Ordering::Greater` notation is too long. Let's use another form of `use`
327-
to import the `enum` variants instead. This will avoid full scoping:
325+
This `Ordering::Greater` notation is too long. Let's use `use` to import the
326+
`enum` variants instead. This will avoid full scoping:
328327

329328
```{rust}
330329
use std::cmp::Ordering::{self, Equal, Less, Greater};
@@ -348,18 +347,16 @@ fn main() {
348347
```
349348

350349
Importing variants is convenient and compact, but can also cause name conflicts,
351-
so do this with caution. For this reason, it's normally considered better style
352-
to `use` an enum rather than its variants directly.
350+
so do this with caution. It's considered good style to rarely import variants
351+
for this reason.
353352

354-
As you can see, `enum`s are quite a powerful tool for data representation, and
355-
are even more useful when they're [generic][generics] across types. Before we
356-
get to generics, though, let's talk about how to use enums with pattern
357-
matching, a tool that will let us deconstruct sum types (the type theory term
358-
for enums) like `Ordering` in a very elegant way that avoids all these messy
359-
and brittle `if`/`else`s.
353+
As you can see, `enum`s are quite a powerful tool for data representation, and are
354+
even more useful when they're [generic][generics] across types. Before we
355+
get to generics, though, let's talk about how to use them with pattern matching, a
356+
tool that will let us deconstruct this sum type (the type theory term for enums)
357+
in a very elegant way and avoid all these messy `if`/`else`s.
360358

361359

362-
[arity]: ./glossary.html#arity
363360
[match]: ./match.html
364361
[game]: ./guessing-game.html#comparing-guesses
365362
[generics]: ./generics.html

branches/tmp/src/doc/trpl/concurrency.md

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,14 +40,14 @@ us enforce that it can't leave the current thread.
4040

4141
### `Sync`
4242

43-
The second of these traits is called [`Sync`](../std/marker/trait.Sync.html).
43+
The second of these two trait is called [`Sync`](../std/marker/trait.Sync.html).
4444
When a type `T` implements `Sync`, it indicates to the compiler that something
4545
of this type has no possibility of introducing memory unsafety when used from
4646
multiple threads concurrently.
4747

4848
For example, sharing immutable data with an atomic reference count is
4949
threadsafe. Rust provides a type like this, `Arc<T>`, and it implements `Sync`,
50-
so it is safe to share between threads.
50+
so that it could be safely shared between threads.
5151

5252
These two traits allow you to use the type system to make strong guarantees
5353
about the properties of your code under concurrency. Before we demonstrate
@@ -69,7 +69,7 @@ fn main() {
6969
}
7070
```
7171

72-
The `thread::scoped()` method accepts a closure, which is executed in a new
72+
The `Thread::scoped()` method accepts a closure, which is executed in a new
7373
thread. It's called `scoped` because this thread returns a join guard:
7474

7575
```
@@ -208,10 +208,10 @@ Here's the error:
208208

209209
```text
210210
<anon>:11:9: 11:22 error: the trait `core::marker::Send` is not implemented for the type `std::sync::mutex::MutexGuard<'_, collections::vec::Vec<u32>>` [E0277]
211-
<anon>:11 thread::spawn(move || {
211+
<anon>:11 Thread::spawn(move || {
212212
^~~~~~~~~~~~~
213213
<anon>:11:9: 11:22 note: `std::sync::mutex::MutexGuard<'_, collections::vec::Vec<u32>>` cannot be sent between threads safely
214-
<anon>:11 thread::spawn(move || {
214+
<anon>:11 Thread::spawn(move || {
215215
^~~~~~~~~~~~~
216216
```
217217

@@ -322,6 +322,7 @@ While this channel is just sending a generic signal, we can send any data that
322322
is `Send` over the channel!
323323

324324
```
325+
use std::sync::{Arc, Mutex};
325326
use std::thread;
326327
use std::sync::mpsc;
327328

branches/tmp/src/doc/trpl/crates-and-modules.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -430,7 +430,7 @@ fn main() {
430430
}
431431
```
432432
433-
But it is not idiomatic. This is significantly more likely to introduce a
433+
But it is not idiomatic. This is significantly more likely to introducing a
434434
naming conflict. In our short program, it's not a big deal, but as it grows, it
435435
becomes a problem. If we have conflicting names, Rust will give a compilation
436436
error. For example, if we made the `japanese` functions public, and tried to do

branches/tmp/src/doc/trpl/standard-input.md

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -115,9 +115,8 @@ doesn't work, so we're okay with that. In most cases, we would want to handle
115115
the error case explicitly. `expect()` allows us to give an error message if
116116
this crash happens.
117117

118-
We will cover the exact details of how all of this works later in the Guide in
119-
[Error Handling]. For now, this gives you enough of a basic understanding to
120-
work with.
118+
We will cover the exact details of how all of this works later in the Guide.
119+
For now, this gives you enough of a basic understanding to work with.
121120

122121
Back to the code we were working on! Here's a refresher:
123122

@@ -158,6 +157,3 @@ here.
158157

159158
That's all you need to get basic input from the standard input! It's not too
160159
complicated, but there are a number of small parts.
161-
162-
163-
[Error Handling]: ./error-handling.html

branches/tmp/src/libcollections/btree/map.rs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ use core::default::Default;
2424
use core::fmt::Debug;
2525
use core::hash::{Hash, Hasher};
2626
use core::iter::{Map, FromIterator, IntoIterator};
27-
use core::ops::{Index};
27+
use core::ops::{Index, IndexMut};
2828
use core::{iter, fmt, mem, usize};
2929
use Bound::{self, Included, Excluded, Unbounded};
3030

@@ -925,6 +925,15 @@ impl<K: Ord, Q: ?Sized, V> Index<Q> for BTreeMap<K, V>
925925
}
926926
}
927927

928+
#[stable(feature = "rust1", since = "1.0.0")]
929+
impl<K: Ord, Q: ?Sized, V> IndexMut<Q> for BTreeMap<K, V>
930+
where K: Borrow<Q>, Q: Ord
931+
{
932+
fn index_mut(&mut self, key: &Q) -> &mut V {
933+
self.get_mut(key).expect("no entry found for key")
934+
}
935+
}
936+
928937
/// Genericises over how to get the correct type of iterator from the correct type
929938
/// of Node ownership.
930939
trait Traverse<N> {

branches/tmp/src/libcollections/str.rs

Lines changed: 9 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,8 @@ use slice::SliceConcatExt;
7474

7575
pub use core::str::{FromStr, Utf8Error, Str};
7676
pub use core::str::{Lines, LinesAny, MatchIndices, SplitStr, CharRange};
77-
pub use core::str::{Split, SplitTerminator, SplitN};
78-
pub use core::str::{RSplit, RSplitN};
77+
pub use core::str::{Split, SplitTerminator};
78+
pub use core::str::{SplitN, RSplitN};
7979
pub use core::str::{from_utf8, CharEq, Chars, CharIndices, Bytes};
8080
pub use core::str::{from_utf8_unchecked, from_c_str, ParseBoolError};
8181
pub use unicode::str::{Words, Graphemes, GraphemeIndices};
@@ -699,48 +699,23 @@ impl str {
699699
core_str::StrExt::split_terminator(&self[..], pat)
700700
}
701701

702-
/// An iterator over substrings of `self`, separated by a pattern,
702+
/// An iterator over substrings of `self`, separated by characters matched by a pattern,
703703
/// starting from the end of the string.
704704
///
705-
/// # Examples
706-
///
707-
/// Simple patterns:
708-
///
709-
/// ```
710-
/// let v: Vec<&str> = "Mary had a little lamb".rsplit(' ').collect();
711-
/// assert_eq!(v, ["lamb", "little", "a", "had", "Mary"]);
712-
///
713-
/// let v: Vec<&str> = "lion::tiger::leopard".rsplit("::").collect();
714-
/// assert_eq!(v, ["leopard", "tiger", "lion"]);
715-
/// ```
705+
/// Restricted to splitting at most `count` times.
716706
///
717-
/// More complex patterns with a lambda:
718-
///
719-
/// ```
720-
/// let v: Vec<&str> = "abc1def2ghi".rsplit(|c: char| c.is_numeric()).collect();
721-
/// assert_eq!(v, ["ghi", "def", "abc"]);
722-
/// ```
723-
#[stable(feature = "rust1", since = "1.0.0")]
724-
pub fn rsplit<'a, P: Pattern<'a>>(&'a self, pat: P) -> RSplit<'a, P>
725-
where P::Searcher: ReverseSearcher<'a>
726-
{
727-
core_str::StrExt::rsplit(&self[..], pat)
728-
}
729-
730-
/// An iterator over substrings of `self`, separated by a pattern,
731-
/// starting from the end of the string, restricted to splitting
732-
/// at most `count` times.
707+
/// The pattern can be a simple `&str`, or a closure that determines the split.
733708
///
734709
/// # Examples
735710
///
736-
/// Simple patterns:
711+
/// Simple `&str` patterns:
737712
///
738713
/// ```
739714
/// let v: Vec<&str> = "Mary had a little lamb".rsplitn(2, ' ').collect();
740715
/// assert_eq!(v, ["lamb", "little", "Mary had a"]);
741716
///
742-
/// let v: Vec<&str> = "lion::tiger::leopard".rsplitn(1, "::").collect();
743-
/// assert_eq!(v, ["leopard", "lion::tiger"]);
717+
/// let v: Vec<&str> = "lionXXtigerXleopard".rsplitn(2, 'X').collect();
718+
/// assert_eq!(v, ["leopard", "tiger", "lionX"]);
744719
/// ```
745720
///
746721
/// More complex patterns with a lambda:
@@ -750,9 +725,7 @@ impl str {
750725
/// assert_eq!(v, ["ghi", "abc1def"]);
751726
/// ```
752727
#[stable(feature = "rust1", since = "1.0.0")]
753-
pub fn rsplitn<'a, P: Pattern<'a>>(&'a self, count: usize, pat: P) -> RSplitN<'a, P>
754-
where P::Searcher: ReverseSearcher<'a>
755-
{
728+
pub fn rsplitn<'a, P: Pattern<'a>>(&'a self, count: usize, pat: P) -> RSplitN<'a, P> {
756729
core_str::StrExt::rsplitn(&self[..], count, pat)
757730
}
758731

0 commit comments

Comments
 (0)