Closed
Description
The following code works:
pub fn new(delay: uint, callback: Box<FnMut() -> uint + 'a>, remove_on_drop: bool) -> Timer<'a> {
...
}
But this doesn't:
pub fn new(delay: uint, callback: Box<(FnMut() -> uint) + 'a>, remove_on_drop: bool) -> Timer<'a> {
...
}
rustc
complains that
src/sdl2/timer.rs:33:43: 33:60 error: expected a path on the left-hand side of `+`, not `(FnMut() -> uint)` [E0178]
src/sdl2/timer.rs:33 pub fn new(delay: uint, callback: Box<(FnMut() -> uint) + 'a>, remove_on_drop: bool) -> Timer<'a> {
^~~~~~~~~~~~~~~~~
src/sdl2/timer.rs:33:43: 33:60 note: perhaps you forgot parentheses? (per RFC 438)
src/sdl2/timer.rs:33 pub fn new(delay: uint, callback: Box<(FnMut() -> uint) + 'a>, remove_on_drop: bool) -> Timer<'a> {
^~~~~~~~~~~~~~~~~
If I understand correctly the syntax is trait + lifetime
, so I'd expect those parentheses to be fine (and imho they make the code more clear). The note about forgetting parentheses is also puzzling.