Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- trait MyFn<T> {
- fn call(self: Box<Self>, arg: &mut T);
- }
- impl<T, F: FnOnce(&mut T)> MyFn<T> for F {
- fn call(self: Box<Self>, arg: &mut T) {
- let this: Self = *self;
- this(arg)
- }
- }
- fn main() {
- let f: Box<MyFn<i32>> = Box::new(|arg: &mut i32| {
- println!("Argument: {}", arg);
- });
- let mut i = 10;
- f.call(&mut i);
- }
Add Comment
Please, Sign In to add comment