This commit is contained in:
Carl Fredrik Samson
2020-01-27 21:46:17 +01:00
parent b1c0bf1ae3
commit 2c884f3d3a

View File

@@ -116,7 +116,7 @@ struct GeneratorA {
impl FnMut<()> for GeneratorA {
type Output = GeneratorState<i32, ()>;
fn call_mut(&mut self) -> Self::Output {
Generatorstate::Yielded(2)
}
}
@@ -130,6 +130,23 @@ impl FnMut<()> for GeneratorA {
>The `yield` keyword was discussed first in [RFC#1823][rfc1823] and in [RFC#1832][rfc1832].
pinning
```ignore
// If we borrow through yield points, we end up with this error
--> src\main.rs:12:11
|
5 | match gen.resume() {
| --- first mutable borrow occurs here
...
12 | match gen.resume() {
| ^^^
| |
| second mutable borrow occurs here
| first borrow later used here
```
[rfc2033]: https://github.com/rust-lang/rfcs/blob/master/text/2033-experimental-coroutines.md
[greenthreads]: https://cfsamson.gitbook.io/green-threads-explained-in-200-lines-of-rust/
[rfc1823]: https://github.com/rust-lang/rfcs/pull/1823