Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
struct Device {
pub data: u32
}
impl Device {
pub fn new() -> Self { Device { data: 0 } }
pub fn async(&mut self) -> BoxFuture<(), ()> {
async_fn().and_then(|result| {
self.data = result;
Ok(())
}).boxed()
}
}
fn async_fn() -> SomeFuture {
// ...
}
fn main() {
let mut device = Device::new();
device.async().wait().unwrap();
println!("{}", device.data);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.