I used a &str
and then switched to OsStr, and the code stopped working because ends_with
stopped returnig a correct result.
Here's the code that reproduces the problem:
use std::{path::Path, ffi::OsStr};
fn main() {
let p1 = "test.osm.gz";
println!("{}", p1.ends_with(".osm.gz"));
let p2 = OsStr::new("test.osm.gz");
let p3 = AsRef::<Path>::as_ref(p2);
println!("{}", p3.ends_with(".osm.gz"));
println!("{}", p3.ends_with(Path::new(".osm.gz")));
}
it prints true
, false
, and false
(I expected all 3 be true
).
Why does this happen?