|
| 1 | +// This issue tests fn_traits overloading on arity. |
| 2 | + |
| 3 | +#![feature(fn_traits)] |
| 4 | +#![feature(unboxed_closures)] |
| 5 | + |
| 6 | +struct Foo; |
| 7 | + |
| 8 | +impl Fn<(isize, isize)> for Foo { |
| 9 | + extern "rust-call" fn call(&self, args: (isize, isize)) -> Self::Output { |
| 10 | + println!("{:?}", args); |
| 11 | + } |
| 12 | +} |
| 13 | + |
| 14 | +impl FnMut<(isize, isize)> for Foo { |
| 15 | + extern "rust-call" fn call_mut(&mut self, args: (isize, isize)) -> Self::Output { |
| 16 | + println!("{:?}", args); |
| 17 | + } |
| 18 | +} |
| 19 | + |
| 20 | +impl FnOnce<(isize, isize)> for Foo { |
| 21 | + type Output = (); |
| 22 | + extern "rust-call" fn call_once(self, args: (isize, isize)) -> Self::Output { |
| 23 | + println!("{:?}", args); |
| 24 | + } |
| 25 | +} |
| 26 | + |
| 27 | +impl Fn<(isize, isize, isize)> for Foo { |
| 28 | + extern "rust-call" fn call(&self, args: (isize, isize, isize)) -> Self::Output { |
| 29 | + println!("{:?}", args); |
| 30 | + } |
| 31 | +} |
| 32 | + |
| 33 | +impl FnMut<(isize, isize, isize)> for Foo { |
| 34 | + extern "rust-call" fn call_mut(&mut self, args: (isize, isize, isize)) -> Self::Output { |
| 35 | + println!("{:?}", args); |
| 36 | + } |
| 37 | +} |
| 38 | +impl FnOnce<(isize, isize, isize)> for Foo { |
| 39 | + type Output = (); |
| 40 | + extern "rust-call" fn call_once(self, args: (isize, isize, isize)) -> Self::Output { |
| 41 | + println!("{:?}", args); |
| 42 | + } |
| 43 | +} |
| 44 | + |
| 45 | +fn main() { |
| 46 | + let foo = Foo; |
| 47 | + foo(1, 1); |
| 48 | +} |
0 commit comments