dtolnay / async-trait

Type erasure for async trait methods
Apache License 2.0
1.81k stars 84 forks source link

Optional sync futures, async block #125

Closed jocutajar closed 4 years ago

jocutajar commented 4 years ago
jocutajar commented 4 years ago

Hi @dtolnay, kindly review.

[SOLVED] Currently when I take my fork as a dependency it fails on syn::* types equality. Any idea? While all is green in async-trait.

[dependencies]
async-trait = { git = "https://github.com/BrightOpen/async-trait.git", branch = "feature/sync-futures-#77" }

results in a few of these:

error[E0369]: binary operation `==` cannot be applied to type `syn::Path`
   --> /home/debian/.cargo/git/checkouts/async-trait-47bf8a75611e2af0/0fe069a/src/expand.rs:113:22
    |
113 |         if attr.path == model.path
    |            --------- ^^ ---------- syn::Path
    |            |
    |            syn::Path
jocutajar commented 4 years ago

binary operation == cannot be applied to type syn::Path

Solved thanks to @link2xt - added "extra-traits" feature for syn.

Meanwhile, added docs and tests, updated README.md

jocutajar commented 4 years ago

Hi @dtolnay, thanks for the feedback.

From your example, I understand that an unused value is dropped before the async block is executed. A useful optimization in the discretion of the compiler without effect on functionality. Perhaps the next version of rust will optimize the async fn similarly...

What would happen if you used the variable in the printout or explicitly dropped it after?

dtolnay commented 4 years ago

I think I'll close for now, since this is pretty hard to review with the unrelated changes included together. Please open a new PR without drop order changes or the readme changes.

jocutajar commented 3 years ago

The improvements plus better support for 'static futures are available in a fork samotop-async-trait