fork/rust
git clone https://git.julia.blue/fork/rust
3bcad65fbf6
master
1error[E0746]: return type cannot have an unboxed trait object 2 --> $DIR/box-instead-of-dyn-fn.rs:5:56 3 | 4LL | fn print_on_or_the_other<'a>(a: i32, b: &'a String) -> dyn Fn() + 'a { 5 | ^^^^^^^^^^^^^ doesn't have a size known at compile-time 6 | 7help: return an `impl Trait` instead of a `dyn Trait`, if all returned values are the same type 8 | 9LL | fn print_on_or_the_other<'a>(a: i32, b: &'a String) -> impl Fn() + 'a { 10 | ~~~~ 11help: box the return type, and wrap all of the returned values in `Box::new` 12 | 13LL ~ fn print_on_or_the_other<'a>(a: i32, b: &'a String) -> Box<dyn Fn() + 'a> { 14LL | 15LL | if a % 2 == 0 { 16LL ~ Box::new(move || println!("{a}")) 17 | 18 19error: aborting due to previous error 20 21For more information about this error, try `rustc --explain E0746`.