Garden 🌻

Path::file_name

The last component of this path.

Path{ p: "/foo/bar.txt" }.file_name() //-> Some("bar.txt")
Path{ p: "/foo/" }.file_name() //-> Some("foo")
Path{ p: "/" }.file_name() //-> None
Source Codepublic method file_name(this: Path): Option<String> {
  if this.p == "/" {
    return None
  }

  this.p.strip_suffix("/").split("/").last()
}