It appears in an error message
error[E0308]: mismatched types
--> irisia-core\src\prop_test.rs:89:17
|
88 | equality_matters &= <fn(&str) -> Gender as HelpUpdate<Gender, T5>>::update(
| ------------------------------------------------------ arguments to this function are incorrect
89 | &Gender::from_str,
| ^^^^^^^^^^^^^^^^^ expected `&fn(&str) -> Gender`, found `&fn(&str) -> Gender {Gender::from_str}`
|
= note: expected reference `&for<'a> fn(&'a str) -> prop_test::Gender`
found reference `&for<'a> fn(&'a str) -> prop_test::Gender {prop_test::Gender::from_str}`
note: method defined here
--> irisia-core\src\element\props\traits.rs:14:8
|
14 | fn update(&self, source: &mut S, maybe_init: T, equality_matters: bool) -> bool;
| ^^^^^^
For more information about this error, try `rustc --explain E0308`.
What's the difference between
&for<'a> fn(&'a str) -> prop_test::Gender
and
&for<'a> fn(&'a str) -> prop_test::Gender {prop_test::Gender::from_str}
the outside function has the trait bound
fn(&str) -> Gender: HelpUpdate<Gender, T5>
the call site is
<fn(&str) -> Gender as HelpUpdate<Gender, T5>>::update(
&Gender::from_str,
&mut self.gender,
updater.gender,
equality_matters,
)
Gender
definition is
#[derive(Clone, Copy, PartialEq)]
enum Gender {
Male,
Female,
Unknown,
}
impl Gender {
fn from_str(string: &str) -> Gender {
// the details have been omitted
todo!()
}
}
HelpUpdate
definition is
impl<S, T> HelpUpdate<S, (T,)> for fn(T) -> S
where
S: PartialEq<S>,
{
fn update(&self, source: &mut S, maybe_init: (T,), equality_matters: bool) -> bool {
// the details have been omitted
todo!();
}
}
Why has this error been thrown?