The syntax for the manual implementation of the Fn* attribute in the structure is:
impl FnOnce<(Arg1,Arg2,Arg3,)> for MyStruct { type Output = MyOutput; extern "rust-call" fn call_once(args: (Arg1, Arg2, Arg3,)) -> MyOutput { // implementation here } }
Note that all arguments are specified as a single tuple.
In addition, this syntax is unstable and requires #![feature(core, unboxed_closures)] , so you cannot use it on the beta channel, only at night.
In your case, it will look like this:
impl FnOnce<(u32,)> for MyErrorPartial { type Output = MyError; extern "rust-call" fn call_once(self, args: (u32,)) -> MyError { MyError { code: args.0, location: self.location, } } }
source share