Closed
Description
Code:
fn main() {
let a = &1;
let b = 1;
if a == b {
println!("equal");
} else {
println!("not equal");
}
}
Error:
error[E0277]: the trait bound `&{integer}: std::cmp::PartialEq<{integer}>` is not satisfied
--> <anon>:4:8
|
4 | if a == b {
| ^^^^^^ the trait `std::cmp::PartialEq<{integer}>` is not implemented for `&{integer}`
|
= help: the following implementations were found:
= help: <&'a A as std::cmp::PartialEq<&'b B>>
= help: <&'a mut A as std::cmp::PartialEq<&'b mut B>>
= help: <&'a A as std::cmp::PartialEq<&'b mut B>>
= help: <&'a mut A as std::cmp::PartialEq<&'b B>>
= help: and 586 others
error: aborting due to previous error
This error message is somewhat intimidating. Assuming the user knows to add a *
or &
, which side do they add it to? It might be not too difficult with this example to deduce that, but when dealing with double nested references and other shenanigans, it'd be a lot easier if we just suggested where to put the *
and &
.