Open
Description
https://play.rust-lang.org/?gist=d912ef0e107be493dd10b72f973897ba
use serde::*;
#[derive(Serialize)]
struct Test;
fn main() {
serialize_wrap(serialize, &Test);
}
fn serialize_wrap<F: FnOnce(&Test)>(f: F, ser: &Test) {
f(ser)
}
fn serialize<T: Serialize>(x: T) {
todo!()
}
The current output is:
error[E0308]: mismatched types
--> src/main.rs:7:5
|
7 | serialize_wrap(serialize, &Test);
| ^^^^^^^^^^^^^^ lifetime mismatch
|
= note: expected type `FnOnce<(&Test,)>`
found type `FnOnce<(&Test,)>`
note: the lifetime requirement is introduced here
--> src/main.rs:10:22
|
10 | fn serialize_wrap<F: FnOnce(&Test)>(f: F, ser: &Test) {
| ^^^^^^^^^^^^^
error: aborting due to previous error
For more information about this error, try `rustc --explain E0308`.
error: could not compile `playground`
To learn more, run the command again with --verbose.
I'm not quite sure what's the right diagnostic here, maybe that it should be by value?