25 lines
1,010 B
Text
25 lines
1,010 B
Text
|
error[E0308]: mismatched types
|
||
|
--> $DIR/suggest-box.rs:4:47
|
||
|
|
|
||
|
LL | let _x: Box<dyn Fn() -> Result<(), ()>> = || {
|
||
|
| _______________________________________________^
|
||
|
LL | | Err(())?;
|
||
|
LL | | Ok(())
|
||
|
LL | | };
|
||
|
| |_____^ expected struct `std::boxed::Box`, found closure
|
||
|
|
|
||
|
= note: expected type `std::boxed::Box<dyn std::ops::Fn() -> std::result::Result<(), ()>>`
|
||
|
found type `[closure@$DIR/suggest-box.rs:4:47: 7:6]`
|
||
|
= note: for more information about 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: you can store this in the heap calling `Box::new`
|
||
|
|
|
||
|
LL | let _x: Box<dyn Fn() -> Result<(), ()>> = Box::new(|| {
|
||
|
LL | Err(())?;
|
||
|
LL | Ok(())
|
||
|
LL | });
|
||
|
|
|
||
|
|
||
|
error: aborting due to previous error
|
||
|
|
||
|
For more information about this error, try `rustc --explain E0308`.
|