From 2c884f3d3ab83ca928b1094789980ee52cda2f0c Mon Sep 17 00:00:00 2001 From: Carl Fredrik Samson Date: Mon, 27 Jan 2020 21:46:17 +0100 Subject: [PATCH] contd --- src/0_1_2_generators_pin.md | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/src/0_1_2_generators_pin.md b/src/0_1_2_generators_pin.md index 61ab694..e246677 100644 --- a/src/0_1_2_generators_pin.md +++ b/src/0_1_2_generators_pin.md @@ -116,7 +116,7 @@ struct GeneratorA { impl FnMut<()> for GeneratorA { type Output = GeneratorState; 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