Closed
Description
I tried this code:
fn check(a: Option<&i32>, b: &i32) -> bool {
a == Some(b)
}
I expected to see this happen: Code compiles and works as expected.
Switching the equality around like this compiles successfully and works as expected:
fn check(a: Option<&i32>, b: &i32) -> bool {
Some(b) == a
}
Alternatively explicitly forcing both references to a shared lifetime works too:
fn check<'c>(a: Option<&'c i32>, b: &'c i32) -> bool {
a == Some(b)
}
Instead, this happened: error[E0495]: cannot infer an appropriate lifetime for automatic coercion due to conflicting requirements
Meta
https://play.rust-lang.org/?gist=9bd7c205c280df1ea37bb49cd3ecca25&version=stable&backtrace=0