Advertisement
Guest User

Untitled

a guest
Jun 18th, 2019
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.49 KB | None | 0 0
  1. use std::{marker::PhantomPinned, pin::Pin};
  2.  
  3. struct Foo(PhantomPinned);
  4.  
  5. impl Foo {
  6. fn new() -> Self {
  7. Foo(PhantomPinned)
  8. }
  9.  
  10. fn poll(self: Pin<&mut Self>) {
  11. println!("Polled on {}", std::thread::current().name().unwrap())
  12. }
  13. }
  14.  
  15. fn main() {
  16. let mut foo = Box::pin(Foo::new());
  17. foo.as_mut().poll();
  18. std::thread::Builder::new()
  19. .name("not main".into())
  20. .spawn(move || foo.as_mut().poll())
  21. .unwrap()
  22. .join()
  23. .unwrap();
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement