Advertisement
Guest User

Untitled

a guest
Oct 16th, 2019
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.36 KB | None | 0 0
  1. use std::future::Future;
  2.  
  3.  
  4. pub struct Foo {}
  5.  
  6. impl Foo {
  7. pub async fn bar(&self) -> Result<i32, ()> {
  8. Ok(42)
  9. }
  10. }
  11.  
  12.  
  13. // Can't use async-std in playground, so here's a shim
  14. pub fn spawn<F, T>(_future: F) where
  15. F: Future<Output = T> + Send + 'static,
  16. T: Send + 'static {
  17. unimplemented!();
  18. }
  19.  
  20. fn main() {
  21. let x = Foo {};
  22. spawn(x.bar());
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement