Guest User

Untitled

a guest
Sep 14th, 2018
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.32 KB | None | 0 0
  1. trait Callable<A> {
  2. fn run(&mut self, input: A);
  3. }
  4.  
  5. impl<A, T: Fn(A)> Callable<A> for T {
  6. fn run(&mut self, input: A) {
  7. self(input);
  8. }
  9. }
  10.  
  11. fn say_hello(v: i32) {
  12. println!("hello {}", v)
  13. }
  14.  
  15. fn process(mut service: impl Callable<i32>, a: i32) {
  16. service.run(a);
  17. }
  18.  
  19. fn main() {
  20. process(say_hello, 33);
  21. }
Add Comment
Please, Sign In to add comment