Rust `ends_with` and `strip_prefix` behavior differences in `Path` and `str`.
While writing an ignore library, I encountered subtle bugs caused by Rust’s Path behavior.
ends_withinPathis different fromends_withinstr: If you try to check whether aPathis a directory by its final character, you’ll find thatpath.ends_with("/")returnsfalse.Path::strip_prefixalso consumes the final slash: If you have a directory marker at the end, such as/Users/emre/mydir/, and pass it tostrip_prefix("/Users/emre"), you’ll getmydirinstead ofmydir/.