]> git.proxmox.com Git - rustc.git/blob - src/test/run-pass/overloaded/overloaded-calls-zero-args.rs
New upstream version 1.37.0+dfsg1
[rustc.git] / src / test / run-pass / overloaded / overloaded-calls-zero-args.rs
1 // run-pass
2
3 #![feature(unboxed_closures, fn_traits)]
4
5 use std::ops::FnMut;
6
7 struct S {
8 x: i32,
9 y: i32,
10 }
11
12 impl FnMut<()> for S {
13 extern "rust-call" fn call_mut(&mut self, (): ()) -> i32 {
14 self.x * self.y
15 }
16 }
17
18 impl FnOnce<()> for S {
19 type Output = i32;
20 extern "rust-call" fn call_once(mut self, args: ()) -> i32 { self.call_mut(args) }
21 }
22
23 fn main() {
24 let mut s = S {
25 x: 3,
26 y: 3,
27 };
28 let ans = s();
29 assert_eq!(ans, 9);
30 }