Skip to content

Commit 196641e

Browse files
zeenixnikomatsakis
andauthored
fixup! status-quo story: Alan needs async in traits
Co-authored-by: Niko Matsakis <[email protected]>
1 parent dd7844c commit 196641e

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

src/vision/status_quo/alan_needs_async_in_traits.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,14 @@ When Alan tries to compile this, he gets an error:
3030
= note: consider using the `async-trait` crate: https://crates.io/crates/async-trait
3131
```
3232

33-
Alan, using Rust for a little while now, has learned to follow compiler error messages and adds `async-trait` to the dependencies list. Alan follows the README of `async-trait` and gets the code to compile. Alan is somewhat dismayed that the compile times have increased considerably after adding this new dependency.
33+
Alan, who has been using Rust for a little while now, has learned to follow compiler error messages and adds `async-trait` to his `Cargo.toml`. Alan follows the README of `async-trait` and comes up with the following code:
34+
'''rust
35+
#[async_trait]
36+
trait HttpClient {
37+
async fn perform(request: Request) -> Response;
38+
}
39+
'''
40+
Alan's code now compiles, but he also finds that his compile times have gone from under a second to around 6s, at least for a clean build.
3441

3542
**TODO::** Maybe add representive pre and post trait compile times here.
3643

0 commit comments

Comments
 (0)