2019-08-12 22:22:58 -05:00
error[E0308]: mismatched types
--> $DIR/suggest-box.rs:4:47
|
LL | let _x: Box<dyn Fn() -> Result<(), ()>> = || {
2019-11-18 23:00:24 -06:00
| _____________-------------------------------___^
| | |
| | expected due to this
2019-08-12 22:22:58 -05:00
LL | | Err(())?;
LL | | Ok(())
LL | | };
2023-01-02 20:00:33 -06:00
| |_____^ expected `Box<dyn Fn() -> Result<(), ()>>`, found closure
2019-08-12 22:22:58 -05:00
|
2021-01-28 10:01:36 -06:00
= note: expected struct `Box<dyn Fn() -> Result<(), ()>>`
2023-09-09 01:36:50 -05:00
found closure `{closure@$DIR/suggest-box.rs:4:47: 4:49}`
2019-08-13 13:24:08 -05:00
= note: for more on the distinction between the stack and the heap, read https://doc.rust-lang.org/book/ch15-01-box.html, https://doc.rust-lang.org/rust-by-example/std/box.html, and https://doc.rust-lang.org/std/boxed/index.html
help: store this in the heap by calling `Box::new`
2019-08-12 22:22:58 -05:00
|
2021-06-21 21:07:19 -05:00
LL ~ let _x: Box<dyn Fn() -> Result<(), ()>> = Box::new(|| {
2019-08-12 22:22:58 -05:00
LL | Err(())?;
LL | Ok(())
2021-06-21 21:07:19 -05:00
LL ~ });
2019-08-12 22:22:58 -05:00
|
error: aborting due to previous error
For more information about this error, try `rustc --explain E0308`.