2016-11-10 11:08:21 -06:00
|
|
|
#![feature(fn_traits, unboxed_closures)]
|
2014-06-01 18:35:01 -05:00
|
|
|
|
|
|
|
use std::ops::FnMut;
|
|
|
|
|
|
|
|
struct S {
|
2015-01-08 04:54:35 -06:00
|
|
|
x: isize,
|
|
|
|
y: isize,
|
2014-06-01 18:35:01 -05:00
|
|
|
}
|
|
|
|
|
2015-01-12 09:27:25 -06:00
|
|
|
impl FnMut<isize> for S {
|
2015-01-08 04:54:35 -06:00
|
|
|
extern "rust-call" fn call_mut(&mut self, z: isize) -> isize {
|
2014-06-01 18:35:01 -05:00
|
|
|
self.x + self.y + z
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-03-11 09:08:33 -05:00
|
|
|
impl FnOnce<isize> for S {
|
|
|
|
type Output = isize;
|
|
|
|
extern "rust-call" fn call_once(mut self, z: isize) -> isize { self.call_mut(z) }
|
|
|
|
}
|
|
|
|
|
2014-06-01 18:35:01 -05:00
|
|
|
fn main() {
|
|
|
|
let mut s = S {
|
|
|
|
x: 1,
|
|
|
|
y: 2,
|
|
|
|
};
|
|
|
|
drop(s(3)) //~ ERROR cannot use call notation
|
|
|
|
}
|