Skip to content

Commit 058565f

Browse files
committed
---
yaml --- r: 217079 b: refs/heads/stable c: ca225df h: refs/heads/master i: 217077: 2c2305a 217075: ab8fd35 217071: 109577a v: v3
1 parent 299c323 commit 058565f

File tree

177 files changed

+4205
-1299
lines changed

Some content is hidden

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

177 files changed

+4205
-1299
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,5 +29,5 @@ refs/heads/tmp: 378a370ff2057afeb1eae86eb6e78c476866a4a6
2929
refs/tags/1.0.0-alpha.2: 4c705f6bc559886632d3871b04f58aab093bfa2f
3030
refs/tags/homu-tmp: a5286998df566e736b32f6795bfc3803bdaf453d
3131
refs/tags/1.0.0-beta: 8cbb92b53468ee2b0c2d3eeb8567005953d40828
32-
refs/heads/stable: e5efea4eb3a75db539fd267ae2574278ec6838bd
32+
refs/heads/stable: ca225df7f328a574638ca45ff2c0c15ff8aeabd2
3333
refs/tags/1.0.0: 55bd4f8ff2b323f317ae89e254ce87162d52a375

branches/stable/AUTHORS.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -736,6 +736,7 @@ Rob Hoelz <[email protected]>
736736
Robert Buonpastore <[email protected]>
737737
Robert Clipsham <[email protected]>
738738
Robert Gawdzik <[email protected]>
739+
Robert Foss <[email protected]>
739740
Robert Irelan <[email protected]>
740741
Robert Knight <[email protected]>
741742
Robert Millar <[email protected]>

branches/stable/README.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -87,9 +87,11 @@ fetch snapshots, and an OS that can execute the available snapshot binaries.
8787

8888
Snapshot binaries are currently built and tested on several platforms:
8989

90-
* Windows (7, 8, Server 2008 R2), x86 and x86-64 (64-bit support added in Rust 0.12.0)
91-
* Linux (2.6.18 or later, various distributions), x86 and x86-64
92-
* OSX 10.7 (Lion) or greater, x86 and x86-64
90+
| Platform \ Architecture | x86 | x86_64 |
91+
|--------------------------------|-----|--------|
92+
| Windows (7, 8, Server 2008 R2) |||
93+
| Linux (2.6.18 or later) |||
94+
| OSX (10.7 Lion or later) |||
9395

9496
You may find that other platforms work, but these are our officially
9597
supported build environments that are most likely to work.

branches/stable/configure

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,8 +106,8 @@ probe() {
106106
T=$(command -v $P 2>&1)
107107
if [ $? -eq 0 ]
108108
then
109-
VER0=$($P --version 2>/dev/null | head -1 \
110-
| sed -e 's/[^0-9]*\([vV]\?[0-9.]\+[^ ]*\).*/\1/' )
109+
VER0=$($P --version 2>/dev/null \
110+
| grep -o '[vV]\?[0-9][0-9.][a-z0-9.-]*' | head -1 )
111111
if [ $? -eq 0 -a "x${VER0}" != "x" ]
112112
then
113113
VER="($VER0)"
@@ -711,6 +711,20 @@ else
711711
probe_need CFG_GIT git
712712
fi
713713

714+
# Use `md5sum` on GNU platforms, or `md5 -q` on BSD
715+
probe CFG_MD5 md5
716+
probe CFG_MD5SUM md5sum
717+
if [ -n "$CFG_MD5" ]
718+
then
719+
CFG_HASH_COMMAND="$CFG_MD5 -q | head -c 8"
720+
elif [ -n "$CFG_MD5SUM" ]
721+
then
722+
CFG_HASH_COMMAND="$CFG_MD5SUM | head -c 8"
723+
else
724+
err 'could not find one of: md5 md5sum'
725+
fi
726+
putvar CFG_HASH_COMMAND
727+
714728
probe CFG_CLANG clang++
715729
probe CFG_CCACHE ccache
716730
probe CFG_GCC gcc

branches/stable/mk/main.mk

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,9 @@ CFG_RELEASE_NUM=1.1.0
2020
# versions (section 9)
2121
CFG_PRERELEASE_VERSION=.1
2222

23-
CFG_FILENAME_EXTRA=4e7c5e5c
23+
# Append a version-dependent hash to each library, so we can install different
24+
# versions in the same place
25+
CFG_FILENAME_EXTRA=$(shell printf '%s' $(CFG_RELEASE) | $(CFG_HASH_COMMAND))
2426

2527
ifeq ($(CFG_RELEASE_CHANNEL),stable)
2628
# This is the normal semver version string, e.g. "0.12.0", "0.12.0-nightly"

branches/stable/src/doc/reference.md

Lines changed: 60 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1346,6 +1346,8 @@ vtable when the trait is used as a [trait object](#trait-objects).
13461346
Traits are implemented for specific types through separate
13471347
[implementations](#implementations).
13481348

1349+
Consider the following trait:
1350+
13491351
```
13501352
# type Surface = i32;
13511353
# type BoundingBox = i32;
@@ -1360,6 +1362,20 @@ This defines a trait with two methods. All values that have
13601362
`draw` and `bounding_box` methods called, using `value.bounding_box()`
13611363
[syntax](#method-call-expressions).
13621364

1365+
Traits can include default implementations of methods, as in:
1366+
1367+
```
1368+
trait Foo {
1369+
fn bar(&self);
1370+
1371+
fn baz(&self) { println!("We called baz."); }
1372+
}
1373+
```
1374+
1375+
Here the `baz` method has a default implementation, so types that implement
1376+
`Foo` need only implement `bar`. It is also possible for implementing types
1377+
to override a method that has a default implementation.
1378+
13631379
Type parameters can be specified for a trait to make it generic. These appear
13641380
after the trait name, using the same syntax used in [generic
13651381
functions](#generic-functions).
@@ -1372,6 +1388,35 @@ trait Seq<T> {
13721388
}
13731389
```
13741390

1391+
It is also possible to define associated types for a trait. Consider the
1392+
following example of a `Container` trait. Notice how the type is available
1393+
for use in the method signatures:
1394+
1395+
```
1396+
trait Container {
1397+
type E;
1398+
fn empty() -> Self;
1399+
fn insert(&mut self, Self::E);
1400+
}
1401+
```
1402+
1403+
In order for a type to implement this trait, it must not only provide
1404+
implementations for every method, but it must specify the type `E`. Here's
1405+
an implementation of `Container` for the standard library type `Vec`:
1406+
1407+
```
1408+
# trait Container {
1409+
# type E;
1410+
# fn empty() -> Self;
1411+
# fn insert(&mut self, Self::E);
1412+
# }
1413+
impl<T> Container for Vec<T> {
1414+
type E = T;
1415+
fn empty() -> Vec<T> { Vec::new() }
1416+
fn insert(&mut self, x: T) { self.push(x); }
1417+
}
1418+
```
1419+
13751420
Generic functions may use traits as _bounds_ on their type parameters. This
13761421
will have two effects: only types that have the trait may instantiate the
13771422
parameter, and within the generic function, the methods of the trait can be
@@ -3470,13 +3515,21 @@ more of the closure traits:
34703515

34713516
### Trait objects
34723517

3473-
Every trait item (see [traits](#traits)) defines a type with the same name as
3474-
the trait. This type is called the _trait object_ of the trait. Trait objects
3475-
permit "late binding" of methods, dispatched using _virtual method tables_
3476-
("vtables"). Whereas most calls to trait methods are "early bound" (statically
3477-
resolved) to specific implementations at compile time, a call to a method on an
3478-
trait objects is only resolved to a vtable entry at compile time. The actual
3479-
implementation for each vtable entry can vary on an object-by-object basis.
3518+
In Rust, a type like `&SomeTrait` or `Box<SomeTrait>` is called a _trait object_.
3519+
Each instance of a trait object includes:
3520+
3521+
- a pointer to an instance of a type `T` that implements `SomeTrait`
3522+
- a _virtual method table_, often just called a _vtable_, which contains, for
3523+
each method of `SomeTrait` that `T` implements, a pointer to `T`'s
3524+
implementation (i.e. a function pointer).
3525+
3526+
The purpose of trait objects is to permit "late binding" of methods. A call to
3527+
a method on a trait object is only resolved to a vtable entry at compile time.
3528+
The actual implementation for each vtable entry can vary on an object-by-object
3529+
basis.
3530+
3531+
Note that for a trait object to be instantiated, the trait must be
3532+
_object-safe_. Object safety rules are defined in [RFC 255][rfc255].
34803533

34813534
Given a pointer-typed expression `E` of type `&T` or `Box<T>`, where `T`
34823535
implements trait `R`, casting `E` to the corresponding pointer type `&R` or

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ data, we call the `clone()` method. In this example, `y` is no longer a referenc
175175
to the vector stored in `x`, but a copy of its first element, `"Hello"`. Now
176176
that we don’t have a reference, our `push()` works just fine.
177177

178-
[move]: move-semantics.html
178+
[move]: ownership.html#move-semantics
179179

180180
If we truly want a reference, we need the other option: ensure that our reference
181181
goes out of scope before we try to do the mutation. That looks like this:

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
* [Hello, Cargo!](hello-cargo.md)
77
* [Learn Rust](learn-rust.md)
88
* [Guessing Game](guessing-game.md)
9+
* [Dining Philosophers](dining-philosophers.md)
10+
* [Rust inside other languages](rust-inside-other-languages.md)
911
* [Effective Rust](effective-rust.md)
1012
* [The Stack and the Heap](the-stack-and-the-heap.md)
1113
* [Testing](testing.md)
@@ -16,6 +18,7 @@
1618
* [Error Handling](error-handling.md)
1719
* [FFI](ffi.md)
1820
* [Borrow and AsRef](borrow-and-asref.md)
21+
* [Release Channels](release-channels.md)
1922
* [Syntax and Semantics](syntax-and-semantics.md)
2023
* [Variable Bindings](variable-bindings.md)
2124
* [Functions](functions.md)
@@ -28,9 +31,9 @@
2831
* [References and Borrowing](references-and-borrowing.md)
2932
* [Lifetimes](lifetimes.md)
3033
* [Mutability](mutability.md)
34+
* [Structs](structs.md)
3135
* [Enums](enums.md)
3236
* [Match](match.md)
33-
* [Structs](structs.md)
3437
* [Patterns](patterns.md)
3538
* [Method Syntax](method-syntax.md)
3639
* [Vectors](vectors.md)
@@ -44,7 +47,6 @@
4447
* [Universal Function Call Syntax](ufcs.md)
4548
* [Crates and Modules](crates-and-modules.md)
4649
* [`const` and `static`](const-and-static.md)
47-
* [Tuple Structs](tuple-structs.md)
4850
* [Attributes](attributes.md)
4951
* [`type` aliases](type-aliases.md)
5052
* [Casting between types](casting-between-types.md)

0 commit comments

Comments
 (0)