From 6d523e9a75fe55eae708d6e606a492f9c891af34 Mon Sep 17 00:00:00 2001 From: mbartlett21 <29034492+mbartlett21@users.noreply.github.com> Date: Thu, 5 May 2022 09:58:13 +1000 Subject: [PATCH] Fix the generator example for `pin!()` --- library/core/src/pin.rs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/library/core/src/pin.rs b/library/core/src/pin.rs index 720317b05e0..ccef35b4532 100644 --- a/library/core/src/pin.rs +++ b/library/core/src/pin.rs @@ -1006,9 +1006,10 @@ impl
DispatchFromDyn where P: DispatchFromDyn {}
/// // Allow generator to be self-referential (not `Unpin`)
/// // vvvvvv so that locals can cross yield points.
/// static || {
-/// let foo = String::from("foo"); // --+
-/// yield 0; // | <- crosses yield point!
-/// println!("{}", &foo); // <----------+
+/// let foo = String::from("foo");
+/// let foo_ref = &foo; // ------+
+/// yield 0; // | <- crosses yield point!
+/// println!("{foo_ref}"); // <--+
/// yield foo.len();
/// }
/// }