Skip to content

Commit b593f0a

Browse files
alexcrichtonZoxc
authored andcommitted
Clarifying documentation for generator
1 parent 3b23269 commit b593f0a

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

src/doc/unstable-book/src/language-features/generators.md

+7-4
Original file line numberDiff line numberDiff line change
@@ -128,14 +128,17 @@ closure-like semantics. Namely:
128128
generator progresses.
129129

130130
* Generator literals produce a value with a unique type which implements the
131-
`std::ops::Generator` trait. This allows actual execution of the genrator
131+
`std::ops::Generator` trait. This allows actual execution of the generator
132132
through the `Generator::resume` method as well as also naming it in return
133133
types and such.
134134

135135
* Traits like `Send` and `Sync` are automatically implemented for a `Generator`
136-
depending on the captured variables of the environment. Note, though, that
137-
generators, like closures, do not implement traits like `Copy` or `Clone`
138-
automatically.
136+
depending on the captured variables of the environment. Unlike closures though
137+
generators also depend on variables live across suspension points. This means
138+
that although the ambient environment may be `Send` or `Sync`, the generator
139+
itself may not be due to internal variables live across `yield` points being
140+
not-`Send` or not-`Sync`. Note, though, that generators, like closures, do
141+
not implement traits like `Copy` or `Clone` automatically.
139142

140143
* Whenever a generator is dropped it will drop all captured environment
141144
variables.

0 commit comments

Comments
 (0)