why this code return false
use std::path::Path;
fn main() {
println!(
"Ends with? {:?}",
&Path::new("some.file.d.ts").ends_with("ts")
);
}
playground link
The documentation is explicit about this:
Determines whether
child
is a suffix ofself
.Only considers whole path components to match
An extension like ts
is not a whole path component.
So, a case where it would be true would be something like:
use std::path::Path;
fn main() {
println!(
"Ends with? {:?}",
&Path::new("/path/to/some.file.d.ts").ends_with("some.file.d.ts")
);
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With