diff options
| author | Esteban Kuber <estebank@users.noreply.github.com> | 2019-11-19 11:29:20 -0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2019-11-19 11:29:20 -0800 |
| commit | a079159c64bfd7b379a9c574d21dbcedb78c5b0c (patch) | |
| tree | bdcbb5f906958b61fac894bd383d47f42a06d153 | |
| parent | 846f5e6bb97c269da4feb171b1837c43de66a38b (diff) | |
| download | rust-a079159c64bfd7b379a9c574d21dbcedb78c5b0c.tar.gz rust-a079159c64bfd7b379a9c574d21dbcedb78c5b0c.zip | |
Remove desugared `async-trait` example
| -rw-r--r-- | src/librustc_error_codes/error_codes/E0706.md | 23 |
1 files changed, 1 insertions, 22 deletions
diff --git a/src/librustc_error_codes/error_codes/E0706.md b/src/librustc_error_codes/error_codes/E0706.md index 909b08fb174..bee9219af7c 100644 --- a/src/librustc_error_codes/error_codes/E0706.md +++ b/src/librustc_error_codes/error_codes/E0706.md @@ -42,28 +42,7 @@ impl MyDatabase { Until these issues are resolved, you can use the [`async-trait` crate], allowing you to use `async fn` in traits by desugaring to "boxed futures" -(`Pin<Box<dyn Future + Send + 'async>>`): - -```edition2018,ignore (example-of-desugaring-equivalence) -#[async_trait] -impl MyDatabase { - async fn get_user(&self) -> User { - unimplemented!() - } -} - -// The annotated impl above gets desugared as follows: -impl MyDatabase { - fn get_user<'async>( - &'async self, - ) -> Pin<Box<dyn std::future::Future<Output = User> + Send + 'async>> - where - Self: Sync + 'async, - { - unimplemented!() - } -} -``` +(`Pin<Box<dyn Future + Send + 'async>>`). Note that using these trait methods will result in a heap allocation per-function-call. This is not a significant cost for the vast majority of applications, but should be considered when deciding |
