From 545810fbdf665aa1d8d3a72be9538cf3000c53c7 Mon Sep 17 00:00:00 2001 From: Manish Goregaokar Date: Mon, 11 Nov 2019 15:33:08 -0800 Subject: [PATCH] Add required hidden definitions to some code examples --- src/07_workarounds/04_send_approximation.md | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/07_workarounds/04_send_approximation.md b/src/07_workarounds/04_send_approximation.md index fd8bcb73..7312f164 100644 --- a/src/07_workarounds/04_send_approximation.md +++ b/src/07_workarounds/04_send_approximation.md @@ -20,6 +20,9 @@ Variables of type `NotSend` can briefly appear as temporaries in `async fn`s even when the resulting `Future` type returned by the `async fn` must be `Send`: ```rust +# use std::rc::Rc; +# #[derive(Default)] +# struct NotSend(Rc<()>); async fn bar() {} async fn foo() { NotSend::default(); @@ -37,6 +40,9 @@ However, if we change `foo` to store `NotSend` in a variable, this example no longer compiles: ```rust +# use std::rc::Rc; +# #[derive(Default)] +# struct NotSend(Rc<()>); async fn foo() { let x = NotSend::default(); bar().await; @@ -80,6 +86,9 @@ for the compiler to tell that these variables do not live across an `.await` point. ```rust +# use std::rc::Rc; +# #[derive(Default)] +# struct NotSend(Rc<()>); async fn foo() { { let x = NotSend::default();