Closed
Description
#![feature(unboxed_closures, unboxed_closure_sugar)]
fn make_adder(a: int, b: int) -> Box<|&:| -> int> {
(box |&:| a + b) as Box<|&:| -> int>
}
fn main() {
println!("{}", make_adder(1, 2).call(()));
}
This code does not compile with this error:
<anon>:8:42: 8:44 error: mismatched types: expected `()` but found `()` (expected tuple but found ())
<anon>:8 println!("{}", make_adder(1, 2).call(()));
^~
note: in expansion of format_args!
<std macros>:2:23: 2:77 note: expansion site
<std macros>:1:1: 3:2 note: in expansion of println!
<anon>:8:5: 8:47 note: expansion site
error: aborting due to previous error
Naturally, call()
without arguments does not work, but I know of no other way to pass zero argument to the closure.
Metadata
Metadata
Assignees
Labels
No labels