This code produce next error:
fn foo<F, R>(f: F)
where F: FnOnce() -> R,
R: IntoItem<Item=()>
{ }
trait IntoItem {
type Item;
}
struct S;
impl IntoItem for S {
type Item = u32;
}
fn main() {
foo(|| S);
}
error:
35 | foo(|| S);
| ^^^ expected u32, found ()
|
= note: expected type `u32`
found type `()`
= note: required by `foo`
This is not correct, because expected type of foo is () (see functon signature).
I'm ask to swap "expected" and "found" notes, because is very confused. For rust
beginners this is embarassing (e.g., an error often occurs when works with tokio crate).
It's also incorrect because underlining is on "foo" keyword, but should to argument.
This error might look like this:
35 | foo(|| S);
| ^^^^ expected (), found u32
|
= note: expected type `()`
found type `u32`
= note: required by `foo`
I suggest making a conclusion about this error easier, such as this:
fn foo(v:u8){ }
fn main(){
foo(25u16); //expected u8, found u16 <-- this is correct
}
This code produce next error:
error:
This is not correct, because expected type of foo is () (see functon signature).
I'm ask to swap "expected" and "found" notes, because is very confused. For rust
beginners this is embarassing (e.g., an error often occurs when works with
tokiocrate).It's also incorrect because underlining is on "foo" keyword, but should to argument.
This error might look like this:
I suggest making a conclusion about this error easier, such as this: