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
fnfoo<'a,X:'static>(mutcb:&mut(FnMut(&u64) -> X + 'a)) -> X{letmut cb = move |expr1| {cb(expr1)};let cb = &mut cb;foo(cb)}// Alternate version which worksfnid<X,T:FnMut(&u64) -> X>(t:T) -> T{ t }fnfoo2<'a,X:'static>(mutcb:&mut(FnMut(&u64) -> X + 'a)) -> X{letmut cb = id(move |expr1| {cb(expr1)});let cb = &mut cb;foo2(cb)}
Gives:
error: type mismatch: the type `[closure@<anon>:2:18: 4:6 cb:_]` implements the trait `std::ops::FnMut<(&u64,)>`, but the trait `for<'r> std::ops::FnMut<(&'r u64,)>` is required (expected concrete lifetime, found bound lifetime parameter ) [--explain E0281]
--> <anon>:6:9
|>
6 |> foo(cb)
|> ^^
note: required for the cast to the object type `for<'r> std::ops::FnMut(&'r u64) -> X`
error: type mismatch resolving `for<'r> <[closure@<anon>:2:18: 4:6 cb:_] as std::ops::FnOnce<(&'r u64,)>>::Output == X`:
expected bound lifetime parameter ,
found concrete lifetime [--explain E0271]
--> <anon>:6:9
|>
6 |> foo(cb)
|> ^^
note: required for the cast to the object type `for<'r> std::ops::FnMut(&'r u64) -> X`
error: aborting due to 2 previous errors
The text was updated successfully, but these errors were encountered:
Gives:
The text was updated successfully, but these errors were encountered: