[−][src]Function libpijul::path::file_name
pub fn file_name(path: &str) -> Option<&str>
Returns the file name of the path. if it exists. This function
tries to replicate the behaviour of std::path::Path::file_name
,
but with &str
instead of Path
.
Like the original, returns None
if the path terminates in ..
.
ⓘThis example is not tested
use libpijul::path::file_name; assert_eq!(file_name("/usr/bin/"), Some("bin")); assert_eq!(file_name("tmp/foo.txt"), Some("foo.txt")); assert_eq!(file_name("foo.txt/."), Some("foo.txt")); assert_eq!(file_name("foo.txt/.//"), Some("foo.txt")); assert_eq!(file_name("foo.txt/.."), None); assert_eq!(file_name("/"), None);