Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add required hidden definitions to some code examples #54

Merged
merged 1 commit into from
Nov 13, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions src/07_workarounds/04_send_approximation.md
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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;
Expand Down Expand Up @@ -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();
Expand Down