Created
March 23, 2020 18:55
-
-
Save matthauck/9743152133266c50d5593a90867b34c1 to your computer and use it in GitHub Desktop.
async-trait, issue #75
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[package] | |
name = "async-trait-75" | |
version = "0.1.0" | |
authors = [] | |
edition = "2018" | |
[dependencies] | |
async-trait = "0.1.17" | |
tokio = { version = "0.2.13", features = [ "rt-threaded", "macros" ] } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ cargo build | |
Compiling async-trait-75 v0.1.0 (/Users/user/async-trait-test) | |
warning: unused implementer of `std::future::Future` that must be used | |
--> src/main.rs:26:5 | |
| | |
26 | thing.do_direct(); | |
| ^^^^^^^^^^^^^^^^^^ | |
| | |
= note: `#[warn(unused_must_use)]` on by default | |
= note: futures do nothing unless you `.await` or poll them | |
Finished dev [unoptimized + debuginfo] target(s) in 1.35s |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#[async_trait::async_trait] | |
trait Interface { | |
async fn do_trait(&self); | |
} | |
struct Thing; | |
#[async_trait::async_trait] | |
impl Interface for Thing { | |
async fn do_trait(&self) { | |
println!("hello from trait"); | |
} | |
} | |
impl Thing { | |
async fn do_direct(&self) { | |
println!("hello from direct"); | |
} | |
} | |
#[tokio::main] | |
async fn main() { | |
let thing = Thing {}; | |
thing.do_trait(); | |
thing.do_direct(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
cf. dtolnay/async-trait#75