Skip to content

Commit 42de89a

Browse files
committed
---
yaml --- r: 63405 b: refs/heads/snap-stage3 c: 5fdb0cb h: refs/heads/master i: 63403: 0bc3d5d v: v3
1 parent 649f943 commit 42de89a

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
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: 2d28d645422c1617be58c8ca7ad9a457264ca850
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
4-
refs/heads/snap-stage3: e014ab9023017ec1c1533a1fbe27288e0b53152f
4+
refs/heads/snap-stage3: 5fdb0cbb8ce98bdddc947fc1eeabd2efd509aadc
55
refs/heads/try: 7b78b52e602bb3ea8174f9b2006bff3315f03ef9
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b

branches/snap-stage3/doc/tutorial.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1941,12 +1941,14 @@ fn head_bad<T>(v: &[T]) -> T {
19411941
~~~~
19421942

19431943
However, we can tell the compiler that the `head` function is only for
1944-
copyable types: that is, those that have the `Copy` trait.
1944+
copyable types: that is, those that have the `Copy` trait. In that
1945+
case, we can explicitly create a second copy of the value we are
1946+
returning using the `copy` keyword:
19451947

19461948
~~~~
19471949
// This does
19481950
fn head<T: Copy>(v: &[T]) -> T {
1949-
v[0]
1951+
copy v[0]
19501952
}
19511953
~~~~
19521954

@@ -2137,7 +2139,7 @@ as in this version of `print_all` that copies elements.
21372139
fn print_all<T: Printable + Copy>(printable_things: ~[T]) {
21382140
let mut i = 0;
21392141
while i < printable_things.len() {
2140-
let copy_of_thing = printable_things[i];
2142+
let copy_of_thing = copy printable_things[i];
21412143
copy_of_thing.print();
21422144
i += 1;
21432145
}

0 commit comments

Comments
 (0)