We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
It doesn't appear to be possible to return a FnBox which accepts references:
#![feature(fnbox)] use std::boxed::FnBox; type Callback = Box<FnBox(&mut usize, &usize)>; fn get_cb() -> Callback { Box::new(|a, b| {}) } fn main() { }
produces the following error on rustc 1.4.0-nightly (cd138dc44 2015-09-02)
rustc 1.4.0-nightly (cd138dc44 2015-09-02)
<anon>:8:5: 10:7 error: type mismatch resolving `for<'r, 'r> <[closure@<anon>:8:14: 10:6] as alloc::boxed::FnBox<(&'r mut usize, &'r usize)>>::Output == ()`: expected bound lifetime parameter , found concrete lifetime [E0271] <anon>: 8 Box::new(|a, b| { <anon>: 9 <anon>:10 }) <anon>:8:5: 10:7 help: see the detailed explanation for E0271 <anon>:8:5: 10:7 note: required for the cast to the object type `for<'r, 'r> alloc::boxed::FnBox<(&'r mut usize, &'r usize), Output=()> + 'static` <anon>: 8 Box::new(|a, b| { <anon>: 9 <anon>:10 }) <anon>:8:5: 10:7 error: type mismatch: the type `[closure@<anon>:8:14: 10:6]` implements the trait `core::ops::FnOnce<(_, _)>`, but the trait `for<'r, 'r> core::ops::FnOnce<(&'r mut usize, &'r usize)>` is required (expected concrete lifetime, found bound lifetime parameter ) [E0281] <anon>: 8 Box::new(|a, b| { <anon>: 9 <anon>:10 }) <anon>:8:5: 10:7 help: see the detailed explanation for E0281 <anon>:8:5: 10:7 note: required for the cast to the object type `for<'r, 'r> alloc::boxed::FnBox<(&'r mut usize, &'r usize), Output=()> + 'static` <anon>: 8 Box::new(|a, b| { <anon>: 9 <anon>:10 }) error: aborting due to 2 previous errors
#25647 is a similar bug when calling FnBox.
The text was updated successfully, but these errors were encountered:
This seems vaguely familiar... you can get around the error by annotating the types of the variables:
#![feature(fnbox)] use std::boxed::FnBox; type Callback = Box<FnBox(&mut usize, &usize)>; fn get_cb() -> Callback { Box::new(|a: &mut _, b: &_| {}) } fn main() { }
Sorry, something went wrong.
Duplicate of #20841.
No branches or pull requests
It doesn't appear to be possible to return a FnBox which accepts references:
produces the following error on
rustc 1.4.0-nightly (cd138dc44 2015-09-02)
#25647 is a similar bug when calling FnBox.
The text was updated successfully, but these errors were encountered: