2019-08-12 20:22:58 -07:00
error[E0308]: mismatched types
--> $DIR/suggest-box.rs:4:47
|
LL | let _x: Box<dyn Fn() -> Result<(), ()>> = || {
2019-11-18 21:00:24 -08:00
| _____________-------------------------------___^
| | |
| | expected due to this
2019-08-12 20:22:58 -07:00
LL | | Err(())?;
LL | | Ok(())
LL | | };
2020-09-02 10:40:56 +03:00
| |_____^ expected struct `Box`, found closure
2019-08-12 20:22:58 -07:00
|
2021-01-28 18:01:36 +02:00
= note: expected struct `Box<dyn Fn() -> Result<(), ()>>`
2022-06-27 07:45:35 +02:00
found closure `[closure@$DIR/suggest-box.rs:4:47: 4:49]`
2019-08-13 11:24:08 -07: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 20:22:58 -07:00
|
2021-06-21 19:07:19 -07:00
LL ~ let _x: Box<dyn Fn() -> Result<(), ()>> = Box::new(|| {
2019-08-12 20:22:58 -07:00
LL | Err(())?;
LL | Ok(())
2021-06-21 19:07:19 -07:00
LL ~ });
2019-08-12 20:22:58 -07:00
|
error: aborting due to previous error
For more information about this error, try `rustc --explain E0308`.