The difference in behavior is due to the context and the exact types involved. In the match
expression, d
is a &&str
, which requires explicit dereferencing to compare with a &str
. but the url.scheme()
comparison has two &str
types (with different lifetimes), which Rust can compare directly. match
expressions are also more strict about types and don't perform automatic dereferencing, unlike some other contexts in Rust.