Created
June 28, 2019 14:27
-
-
Save pimeys/0ad986fc757406b7c009318dc7458589 to your computer and use it in GitHub Desktop.
This file contains 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
#![feature(async_await, await_macro)] | |
#![recursion_limit = "128"] | |
use futures01::future::lazy; | |
use futures03::future::{FutureExt, TryFutureExt}; | |
pub struct Server { | |
name: String, | |
} | |
impl Server { | |
async fn get_name(&self) -> String { | |
self.name.clone() | |
} | |
async fn print_name(&self) { | |
let name = self.get_name().await; | |
println!("Hello, world! Your name is {}!", name); | |
} | |
} | |
fn main() { | |
let server = Server { | |
name: String::from("Musti"), | |
}; | |
let fut = server.print_name().unit_error().boxed().compat(); | |
tokio::run(fut); | |
} |
Author
pimeys
commented
Jun 28, 2019
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment