Closed
Description
Godbolt link: https://rust.godbolt.org/z/bAU2UA
I expect these two snippets have the same optimized asm but they don't:
use std::ffi::OsStr;
pub fn foo(s: Option<&OsStr>) -> bool {
s.map_or(false, |x| x == OsStr::new("so"))
}
use std::ffi::OsStr;
pub fn foo(s: Option<&OsStr>) -> bool {
s == Some(OsStr::new("so"))
}