Skip to content

(Mini) Rollup of 15 pull requests #23660

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 32 commits into from
Closed
Changes from 2 commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
0c040b0
guide: minor copy edits
ches Mar 2, 2015
92294e7
guide: Improvements to language covering enums
ches Mar 2, 2015
c175b35
fix the attributes sytax
FuGangqiang Mar 21, 2015
bc9d9f2
add lifetime for `while` and `for` expression
FuGangqiang Mar 21, 2015
90c8592
Refine Cursor docstring
nagisa Mar 22, 2015
5321d22
Remove bad reference to std::io
steveklabnik Mar 22, 2015
fbc823d
Document how to document macros
steveklabnik Mar 22, 2015
81801f2
Re-word explanation on closures in intro
steveklabnik Mar 22, 2015
d944689
Fix dead link for std::sync::mpsc.
WiSaGaN Mar 23, 2015
2750e3c
Add note about pointer state after the call.
steveklabnik Mar 20, 2015
d6fb7e9
derive missing trait implementations for cursor
mahkoh Mar 22, 2015
a5e1cbe
Beef up BufRead::consume documentation.
steveklabnik Mar 22, 2015
d52c362
Clarify that slices don't just point to arrays
steveklabnik Mar 23, 2015
05c9728
Don't conflate regions and affine types
steveklabnik Mar 23, 2015
1be8fcb
Make note of str in 'more strings' chapter
steveklabnik Mar 23, 2015
248b2ec
Stabilize Entry types
aturon Mar 19, 2015
3f52d71
Update docs for ptr module.
mbrubeck Mar 23, 2015
1f984c6
Rollup merge of #22954 - ches:docs, r=steveklabnik
Manishearth Mar 24, 2015
413c0c9
Rollup merge of #23509 - aturon:stab-entry, r=aturon
Manishearth Mar 24, 2015
566becb
Rollup merge of #23561 - steveklabnik:gh23422, r=alexcrichton
Manishearth Mar 24, 2015
2b19ddb
Rollup merge of #23590 - FuGangqiang:attr, r=alexcrichton
Manishearth Mar 24, 2015
847118f
Rollup merge of #23607 - mahkoh:cursor, r=alexcrichton
Manishearth Mar 24, 2015
cc76e09
Rollup merge of #23608 - nagisa:refine-cursor-docstring, r=steveklabnik
Manishearth Mar 24, 2015
3a021fa
Rollup merge of #23615 - steveklabnik:gh23540, r=alexcrichton
Manishearth Mar 24, 2015
01e94e7
Rollup merge of #23618 - steveklabnik:gh23571, r=alexcrichton
Manishearth Mar 24, 2015
b5e841b
Rollup merge of #23619 - steveklabnik:gh23220, r=alexcrichton
Manishearth Mar 24, 2015
408e6bd
Rollup merge of #23622 - steveklabnik:gh23196, r=alexcrichton
Manishearth Mar 24, 2015
10ab1cb
Rollup merge of #23634 - WiSaGaN:bugfix/fix_dead_link, r=steveklabnik
Manishearth Mar 24, 2015
0175198
Rollup merge of #23639 - steveklabnik:gh21305, r=alexcrichton
Manishearth Mar 24, 2015
12c7e37
Rollup merge of #23641 - steveklabnik:gh23632, r=alexcrichton
Manishearth Mar 24, 2015
4c11af4
Rollup merge of #23644 - mbrubeck:doc-edit, r=steveklabnik
Manishearth Mar 24, 2015
01a7947
Rollup merge of #23645 - steveklabnik:gh23642, r=brson
Manishearth Mar 24, 2015
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 10 additions & 10 deletions src/doc/intro.md
Original file line number Diff line number Diff line change
Expand Up @@ -446,16 +446,16 @@ It gives us this error:
error: aborting due to previous error
```

It mentions that "captured outer variable in an `FnMut` closure".
Because we declared the closure as a moving closure, and it referred
to `numbers`, the closure will try to take ownership of the
vector. But the closure itself is created in a loop, and hence we will
actually create three closures, one for every iteration of the
loop. This means that all three of those closures would try to own
`numbers`, which is impossible -- `numbers` must have just one
owner. Rust detects this and gives us the error: we claim that
`numbers` has ownership, but our code tries to make three owners. This
may cause a safety problem, so Rust disallows it.
This is a little confusing because there are two closures here: the one passed
to `map`, and the one passed to `thread::scoped`. In this case, the closure for
`thread::scoped` is attempting to reference `numbers`, a `Vec<i32>`. This
closure is a `FnOnce` closure, as that’s what `thread::scoped` takes as an
argument. `FnOnce` closures take ownership of their environment. That’s fine,
but there’s one detail: because of `map`, we’re going to make three of these
closures. And since all three try to take ownership of `numbers`, that would be
a problem. That’s what it means by ‘cannot move out of captured outer
variable’: our `thread::scoped` closure wants to take ownership, and it can’t,
because the closure for `map` won’t let it.

What to do here? Rust has two types that helps us: `Arc<T>` and `Mutex<T>`.
*Arc* stands for "atomically reference counted". In other words, an Arc will
Expand Down