Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- trait Callable<A> {
- fn run(&mut self, input: A);
- }
- impl<A, T: Fn(A)> Callable<A> for T {
- fn run(&mut self, input: A) {
- self(input);
- }
- }
- fn say_hello(v: i32) {
- println!("hello {}", v)
- }
- fn process(mut service: impl Callable<i32>, a: i32) {
- service.run(a);
- }
- fn main() {
- process(say_hello, 33);
- }
Add Comment
Please, Sign In to add comment