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
error[E0631]: type mismatch in closure arguments
--> src/main.rs:1:28
|
1 | fn doesnt_work() -> Result<impl FnMut(&u32, Option<u32>) -> bool, ()> {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected signature of `for<'r> fn(&'r u32, std::option::Option<u32>) -> _`
2 | Ok(|current, msg| false)
| -------------------- found signature of `fn(_, _) -> _`
|
= note: the return type of a function must have a statically known size
error[E0271]: type mismatch resolving `for<'r> <[closure@src/main.rs:2:8: 2:28] as std::ops::FnOnce<(&'r u32, std::option::Option<u32>)>>::Output == bool`
--> src/main.rs:1:28
|
1 | fn doesnt_work() -> Result<impl FnMut(&u32, Option<u32>) -> bool, ()> {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected bound lifetime parameter, found concrete lifetime
|
= note: the return type of a function must have a statically known size
error: aborting due to 2 previous errors
Thanks to fix this issue.
The text was updated successfully, but these errors were encountered:
csmoe
added
the
A-impl-trait
Area: `impl Trait`. Universally / existentially quantified anonymous types with static dispatch.
label
Oct 2, 2018
Notably, Ok(|current: &_, msg| false) resolves the error. I guess closures in output position for -> impl Fn receive the same special-case treatment from the type checker that those in argument position do?
Hi.
It compiles with a type annotation as in this code.
This code doesn't compile.
error:
Thanks to fix this issue.
The text was updated successfully, but these errors were encountered: