Skip to content

Commit c6226c9

Browse files
committed
---
yaml --- r: 210678 b: refs/heads/try c: 9a3e98b h: refs/heads/master v: v3
1 parent db712b8 commit c6226c9

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

+691
-1765
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
refs/heads/master: 3e561f05c00cd180ec02db4ccab2840a4aba93d2
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: ba0e1cd8147d452c356aacb29fb87568ca26f111
5-
refs/heads/try: 3dee0df02568610639e676b61bf8f9de0b2699c4
5+
refs/heads/try: 9a3e98be1c20781e566d12d14940c8dd3d237b15
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/dist-snap: ba4081a5a8573875fed17545846f6f6902c8ba8d
88
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596

branches/try/src/doc/index.md

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,15 @@ to jump to any particular section.
55

66
# Getting Started
77

8-
If you haven't seen Rust at all yet, the first thing you should read is the
9-
introduction to [The Rust Programming Language](book/index.html). It'll give
10-
you a good idea of what Rust is like.
8+
If you haven't seen Rust at all yet, the first thing you should read is the [30
9+
minute intro](intro.html). It will give you an overview of the basic ideas of Rust
10+
at a high level.
1111

12-
The book provides a lengthy explanation of Rust, its syntax, and its
13-
concepts. Upon completing the book, you'll be an intermediate Rust
14-
developer, and will have a good grasp of the fundamental ideas behind
15-
Rust.
12+
Once you know you really want to learn Rust, the next step is reading [The
13+
Rust Programming Language](book/index.html). It is a lengthy explanation of
14+
Rust, its syntax, and its concepts. Upon completing the book, you'll be an
15+
intermediate Rust developer, and will have a good grasp of the fundamental
16+
ideas behind Rust.
1617

1718
[Rust By Example][rbe] was originally a community resource, but was then
1819
donated to the Rust project. As the name implies, it teaches you Rust through a
@@ -23,7 +24,7 @@ series of small examples.
2324
# Community & Getting Help
2425

2526
If you need help with something, or just want to talk about Rust with others,
26-
there are a few places you can do that:
27+
there's a few places you can do that:
2728

2829
The Rust IRC channels on [irc.mozilla.org](http://irc.mozilla.org/) are the
2930
fastest way to get help.
@@ -58,7 +59,7 @@ the language in as much detail as possible is in [the reference](reference.html)
5859

5960
# Tools
6061

61-
Rust is still a young language, so there isn't a ton of tooling yet, but the
62+
Rust's still a young language, so there isn't a ton of tooling yet, but the
6263
tools we have are really nice.
6364

6465
[Cargo](http://crates.io) is Rust's package manager, and its website contains
@@ -68,21 +69,16 @@ lots of good documentation.
6869

6970
# FAQs
7071

71-
There are questions that are asked quite often, so we've made FAQs for them:
72+
There are questions that are asked quite often, and so we've made FAQs for them:
7273

7374
* [Language Design FAQ](complement-design-faq.html)
7475
* [Language FAQ](complement-lang-faq.html)
7576
* [Project FAQ](complement-project-faq.html)
7677
* [How to submit a bug report](https://github.com/rust-lang/rust/blob/master/CONTRIBUTING.md#bug-reports)
7778

78-
# The Standard Library
79+
# The standard library
7980

8081
We have [API documentation for the entire standard
8182
library](std/index.html). There's a list of crates on the left with more
8283
specific sections, or you can use the search bar at the top to search for
8384
something if you know its name.
84-
85-
# The Error Index
86-
87-
If you encounter an error while compiling your code you may be able to look it
88-
up in the [Rust Compiler Error Index](error-index.html).

branches/try/src/doc/reference.md

Lines changed: 73 additions & 169 deletions
Large diffs are not rendered by default.

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
* [Concurrency](concurrency.md)
1616
* [Error Handling](error-handling.md)
1717
* [FFI](ffi.md)
18-
* [Borrow and AsRef](borrow-and-asref.md)
1918
* [Syntax and Semantics](syntax-and-semantics.md)
2019
* [Variable Bindings](variable-bindings.md)
2120
* [Functions](functions.md)

branches/try/src/doc/trpl/borrow-and-asref.md

Lines changed: 0 additions & 93 deletions
This file was deleted.

branches/try/src/doc/trpl/compiler-plugins.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ for a full example, the core of which is reproduced here:
176176

177177
```ignore
178178
declare_lint!(TEST_LINT, Warn,
179-
"Warn about items named 'lintme'");
179+
"Warn about items named 'lintme'")
180180
181181
struct Pass;
182182

branches/try/src/doc/trpl/drop.md

Lines changed: 66 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,67 @@
1-
% `Drop`
1+
% Drop
22

3-
Coming soon!
3+
Now that we’ve discussed traits, let’s talk about a particular trait provided
4+
by the Rust standard library, [`Drop`][drop]. The `Drop` trait provides a way
5+
to run some code when a value goes out of scope. For example:
6+
7+
[drop]: ../std/ops/trait.Drop.html
8+
9+
```rust
10+
struct HasDrop;
11+
12+
impl Drop for HasDrop {
13+
fn drop(&mut self) {
14+
println!("Dropping!");
15+
}
16+
}
17+
18+
fn main() {
19+
let x = HasDrop;
20+
21+
// do stuff
22+
23+
} // x goes out of scope here
24+
```
25+
26+
When `x` goes out of scope at the end of `main()`, the code for `Drop` will
27+
run. `Drop` has one method, which is also called `drop()`. It takes a mutable
28+
reference to `self`.
29+
30+
That’s it! The mechanics of `Drop` are very simple, but there are some
31+
subtleties. For example, values are dropped in the opposite order they are
32+
declared. Here’s another example:
33+
34+
```rust
35+
struct Firework {
36+
strength: i32,
37+
}
38+
39+
impl Drop for Firework {
40+
fn drop(&mut self) {
41+
println!("BOOM times {}!!!", self.strength);
42+
}
43+
}
44+
45+
fn main() {
46+
let firecracker = Firework { strength: 1 };
47+
let tnt = Firework { strength: 100 };
48+
}
49+
```
50+
51+
This will output:
52+
53+
```text
54+
BOOM times 100!!!
55+
BOOM times 1!!!
56+
```
57+
58+
The TNT goes off before the firecracker does, because it was declared
59+
afterwards. Last in, first out.
60+
61+
So what is `Drop` good for? Generally, `Drop` is used to clean up any resources
62+
associated with a `struct`. For example, the [`Arc<T>` type][arc] is a
63+
reference-counted type. When `Drop` is called, it will decrement the reference
64+
count, and if the total number of references is zero, will clean up the
65+
underlying value.
66+
67+
[arc]: ../std/sync/struct.Arc.html

branches/try/src/doc/trpl/lifetimes.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ Rust’s most unique and compelling features, with which Rust developers should
55
become quite acquainted. Ownership is how Rust achieves its largest goal,
66
memory safety. There are a few distinct concepts, each with its own chapter:
77

8-
* [ownership][ownership], the key concept
8+
* [ownership][ownership], ownership, the key concept
99
* [borrowing][borrowing], and their associated feature ‘references’
1010
* lifetimes, which you’re reading now
1111

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -127,12 +127,12 @@ fn grow(&self) -> Circle {
127127
We just say we’re returning a `Circle`. With this method, we can grow a new
128128
circle to any arbitrary size.
129129

130-
# Associated functions
130+
# Static methods
131131

132-
You can also define associated functions that do not take a `self` parameter.
133-
Here’s a pattern that’s very common in Rust code:
132+
You can also define static methods that do not take a `self` parameter. Here’s a
133+
pattern that’s very common in Rust code:
134134

135-
```rust
135+
```
136136
struct Circle {
137137
x: f64,
138138
y: f64,

branches/try/src/doc/trpl/ownership.md

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ become quite acquainted. Ownership is how Rust achieves its largest goal,
66
memory safety. There are a few distinct concepts, each with its own
77
chapter:
88

9-
* ownership, which you’re reading now
9+
* ownership, which you’re reading now.
1010
* [borrowing][borrowing], and their associated feature ‘references’
1111
* [lifetimes][lifetimes], an advanced concept of borrowing
1212

@@ -23,7 +23,7 @@ Before we get to the details, two important notes about the ownership system.
2323
Rust has a focus on safety and speed. It accomplishes these goals through many
2424
‘zero-cost abstractions’, which means that in Rust, abstractions cost as little
2525
as possible in order to make them work. The ownership system is a prime example
26-
of a zero-cost abstraction. All of the analysis we’ll talk about in this guide
26+
of a zero cost abstraction. All of the analysis we’ll talk about in this guide
2727
is _done at compile time_. You do not pay any run-time cost for any of these
2828
features.
2929

@@ -41,7 +41,7 @@ With that in mind, let’s learn about ownership.
4141

4242
# Ownership
4343

44-
[Variable bindings][bindings] have a property in Rust: they ‘have ownership’
44+
[`Variable bindings`][bindings] have a property in Rust: they ‘have ownership’
4545
of what they’re bound to. This means that when a binding goes out of scope, the
4646
resource that they’re bound to are freed. For example:
4747

@@ -106,8 +106,8 @@ take(v);
106106
println!("v[0] is: {}", v[0]);
107107
```
108108

109-
Same error: use of moved value’. When we transfer ownership to something else,
110-
we say that we’ve ‘moved’ the thing we refer to. You don’t need any sort of
109+
Same error: use of moved value.” When we transfer ownership to something else,
110+
we say that we’ve ‘moved’ the thing we refer to. You don’t need some sort of
111111
special annotation here, it’s the default thing that Rust does.
112112

113113
## The details
@@ -121,19 +121,19 @@ let v = vec![1, 2, 3];
121121
let v2 = v;
122122
```
123123

124-
The first line allocates memory for the vector object, `v`, and for the data it
125-
contains. The vector object is stored on the [stack][sh] and contains a pointer
126-
to the content (`[1, 2, 3]`) stored on the [heap][sh]. When we move `v` to `v2`,
127-
it creates a copy of that pointer, for `v2`. Which means that there would be two
128-
pointers to the content of the vector on the heap. It would violate Rust’s
129-
safety guarantees by introducing a data race. Therefore, Rust forbids using `v`
130-
after we’ve done the move.
124+
The first line creates some data for the vector on the [stack][sh], `v`. The
125+
vector’s data, however, is stored on the [heap][sh], and so it contains a
126+
pointer to that data. When we move `v` to `v2`, it creates a copy of that pointer,
127+
for `v2`. Which would mean two pointers to the contents of the vector on the
128+
heap. That would be a problem: it would violate Rust’s safety guarantees by
129+
introducing a data race. Therefore, Rust forbids using `v` after we’ve done the
130+
move.
131131

132132
[sh]: the-stack-and-the-heap.html
133133

134134
It’s also important to note that optimizations may remove the actual copy of
135-
the bytes on the stack, depending on circumstances. So it may not be as
136-
inefficient as it initially seems.
135+
the bytes, depending on circumstances. So it may not be as inefficient as it
136+
initially seems.
137137

138138
## `Copy` types
139139

branches/try/src/doc/trpl/primitive-types.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ let x = true;
1515
let y: bool = false;
1616
```
1717

18-
A common use of booleans is in [`if` conditionals][if].
18+
A common use of booleans is in [`if` statements][if].
1919

2020
[if]: if.html
2121

0 commit comments

Comments
 (0)