Posted on :: Tags: , , ,

As I’m writing an ignore library, I’m having subtle bugs caused by Rust’s Path behavior.

  • ends_with in Path is different from ends_with of str If you try to check whether the Path is a directory by the final character, you’ll see that path.ends_with("/") returns false.

  • Path::strip_prefix eats also the final slash. This means if you have a directory marker at the end, /Users/emre/mydir/ and send it to strip_prefix("/Users/emre"), you’ll get mydir, not mydir/.