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

Update explanation to show async block expansion #255

Merged
merged 1 commit into from
Dec 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 3 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ can't be that badly broken.
## Explanation

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

For example the `impl Advertisement for AutoplayingVideo` above would be
expanded as:
Expand All @@ -131,11 +131,9 @@ impl Advertisement for AutoplayingVideo {
where
Self: Sync + 'async_trait,
{
async fn run(_self: &AutoplayingVideo) {
Box::pin(async move {
/* the original method body */
}

Box::pin(run(self))
})
}
}
```
Expand Down
8 changes: 3 additions & 5 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@
//! # Explanation
//!
//! Async fns get transformed into methods that return `Pin<Box<dyn Future +
//! Send + 'async_trait>>` and delegate to a private async freestanding function.
//! Send + 'async_trait>>` and delegate to an async block.
//!
//! For example the `impl Advertisement for AutoplayingVideo` above would be
//! expanded as:
Expand All @@ -147,11 +147,9 @@
//! where
//! Self: Sync + 'async_trait,
//! {
//! async fn run(_self: &AutoplayingVideo) {
//! Box::pin(async move {
//! /* the original method body */
//! }
//!
//! Box::pin(run(self))
//! })
//! }
//! }
//! # };
Expand Down