daily pastebin goal
22%
SHARE
TWEET

Untitled

a guest Sep 14th, 2018 51 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top