Guest User

Untitled

a guest
Aug 14th, 2018
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.37 KB | None | 0 0
  1. struct Foo {
  2. some_data: i32,
  3. }
  4.  
  5. impl Foo {
  6. fn some_func(&self) {
  7. println!("{}", self.some_data)
  8. }
  9.  
  10. fn run<T, F>(&self, data: &T, func: F)
  11. where F: Fn(&T) + 'static
  12. {
  13. func(data);
  14. }
  15.  
  16. fn exec(&self) {
  17. self.run(self, &Foo::some_func);
  18. }
  19. }
  20.  
  21.  
  22. fn main() {
  23. let foo = Foo { some_data: 0x666 };
  24. foo.exec();
  25. }
Add Comment
Please, Sign In to add comment