You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
There seems to be no way to use a ~fn inside an Option without rewriting the type every time you use it. This line:
let _:Option<~fn()> = Some(|| {});
gives this error message:
error: mismatched types: expected `std::option::Option<~fn:Send()>` but found `std::option::Option<&fn<no-bounds>()>` (expected ~ closure, found & closure)
The problem is that the function inside the Some is interpreted to be a &fn rather than a ~fn, and then the compiler complains about a type mismatch. The only way to make it work is this to make it Some::<~fn()>(|| { }) instead. But when the function isn't just ~fn() and has parameters and a return type, that becomes extremely annoying.
The text was updated successfully, but these errors were encountered:
This does not appear to be an issue anymore, ever since the change to proc instead of fn. The syntax is different than a &fn, so the compiler can no longer get confused. The equivalent code after the change: let _:Option<proc()> = Some(proc() {}) compiles just fine. Closing this.
There seems to be no way to use a ~fn inside an Option without rewriting the type every time you use it. This line:
gives this error message:
The problem is that the function inside the
Some
is interpreted to be a &fn rather than a ~fn, and then the compiler complains about a type mismatch. The only way to make it work is this to make itSome::<~fn()>(|| { })
instead. But when the function isn't just~fn()
and has parameters and a return type, that becomes extremely annoying.The text was updated successfully, but these errors were encountered: