Skip to content

Commit 381fd75

Browse files
committed
Update explanation to show async block expansion
1 parent 3caf301 commit 381fd75

File tree

2 files changed

+6
-10
lines changed

2 files changed

+6
-10
lines changed

README.md

+3-5
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ can't be that badly broken.
118118
## Explanation
119119

120120
Async fns get transformed into methods that return `Pin<Box<dyn Future + Send +
121-
'async_trait>>` and delegate to a private async freestanding function.
121+
'async_trait>>` and delegate to an async block.
122122

123123
For example the `impl Advertisement for AutoplayingVideo` above would be
124124
expanded as:
@@ -131,11 +131,9 @@ impl Advertisement for AutoplayingVideo {
131131
where
132132
Self: Sync + 'async_trait,
133133
{
134-
async fn run(_self: &AutoplayingVideo) {
134+
Box::pin(async move {
135135
/* the original method body */
136-
}
137-
138-
Box::pin(run(self))
136+
})
139137
}
140138
}
141139
```

src/lib.rs

+3-5
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@
133133
//! # Explanation
134134
//!
135135
//! Async fns get transformed into methods that return `Pin<Box<dyn Future +
136-
//! Send + 'async_trait>>` and delegate to a private async freestanding function.
136+
//! Send + 'async_trait>>` and delegate to an async block.
137137
//!
138138
//! For example the `impl Advertisement for AutoplayingVideo` above would be
139139
//! expanded as:
@@ -147,11 +147,9 @@
147147
//! where
148148
//! Self: Sync + 'async_trait,
149149
//! {
150-
//! async fn run(_self: &AutoplayingVideo) {
150+
//! Box::pin(async move {
151151
//! /* the original method body */
152-
//! }
153-
//!
154-
//! Box::pin(run(self))
152+
//! })
155153
//! }
156154
//! }
157155
//! # };

0 commit comments

Comments
 (0)