Skip to content

Commit a32adc4

Browse files
committed
---
yaml --- r: 208814 b: refs/heads/snap-stage3 c: 38a97be h: refs/heads/master v: v3
1 parent 81d39ce commit a32adc4

File tree

5 files changed

+15
-7
lines changed

5 files changed

+15
-7
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
refs/heads/master: 38a97becdf3e6a6157f6f7ec2d98ade8d8edc193
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
4-
refs/heads/snap-stage3: deaa1172cf2871e04ca2524b6b553afb143f677a
4+
refs/heads/snap-stage3: 38a97becdf3e6a6157f6f7ec2d98ade8d8edc193
55
refs/heads/try: 7b4ef47b7805a402d756fb8157101f64880a522f
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/dist-snap: ba4081a5a8573875fed17545846f6f6902c8ba8d

branches/snap-stage3/src/doc/reference.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3622,6 +3622,14 @@ The `Sized` trait indicates that the size of this type is known at compile-time.
36223622
The `Drop` trait provides a destructor, to be run whenever a value of this type
36233623
is to be destroyed.
36243624

3625+
## The `Deref` trait
3626+
3627+
The `Deref<Target = U>` trait allows a type to implicitly implement all the methods
3628+
of the type `U`. When attempting to resolve a method call, the compiler will search
3629+
the top-level type for the implementation of the called method. If no such method is
3630+
found, `.deref()` is called and the compiler continues to search for the method
3631+
implementation in the returned type `U`.
3632+
36253633
# Memory model
36263634

36273635
A Rust program's memory consists of a static set of *items* and a *heap*.

branches/snap-stage3/src/doc/trpl/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -150,8 +150,8 @@ of those times. As the error explains, while we made our binding mutable, we
150150
still cannot call `push`. This is because we already have a reference to an
151151
element of the vector, `y`. Mutating something while another reference exists
152152
is dangerous, because we may invalidate the reference. In this specific case,
153-
when we create the vector, we may have only allocated space for three elements.
154-
Adding a fourth would mean allocating a new chunk of memory for all those elements,
153+
when we create the vector, we may have only allocated space for two elements.
154+
Adding a third would mean allocating a new chunk of memory for all those elements,
155155
copying the old values over, and updating the internal pointer to that memory.
156156
That all works just fine. The problem is that `y` wouldn’t get updated, and so
157157
we’d have a ‘dangling pointer’. That’s bad. Any use of `y` would be an error in

branches/snap-stage3/src/doc/trpl/guessing-game.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ a few tricks up their sleeves.
148148
For example, they’re [immutable][immutable] by default. That’s why our example
149149
uses `mut`: it makes a binding mutable, rather than immutable. `let` doesn’t
150150
take a name on the left hand side, it actually accepts a
151-
[pattern][patterns]’. We’ll use patterns more later. It’s easy enough
151+
[pattern][patterns]’. We’ll use patterns later. It’s easy enough
152152
to use for now:
153153

154154
```rust

branches/snap-stage3/src/doc/trpl/the-stack-and-the-heap.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -277,9 +277,9 @@ allocated on the heap:
277277
| 0 | x | ?????? |
278278

279279
[drop]: drop.html
280-
[moving]: We can make the memory live longer by transferring ownership,
281-
sometimes called ‘moving out of the box’. More complex examples will
282-
be covered later.
280+
[^moving]: We can make the memory live longer by transferring ownership,
281+
sometimes called ‘moving out of the box’. More complex examples will
282+
be covered later.
283283

284284

285285
And then the stack frame goes away, freeing all of our memory.

0 commit comments

Comments
 (0)