eq()
on OsString
RS-W1134The eq()
method on the OsString
type can be used to compare against
&str
, and &OsStr
too. Consider using this instead of manually
implementing the comparison with to_str().map(.. == )
.
use std::ffi::OsString;
fn foo() {
let s1: OsString = OsString::from("Hello there");
if s1.to_str().map(|s| s == "Hello there").unwrap_or_default() {
println!("Matches!");
}
}
use std::ffi::OsString;
fn foo() {
let s1: OsString = OsString::from("Hello there");
if s1.eq("Hello there") {
println!("Matches!");
}
}