get_last_path_component

Function get_last_path_component 

Source
pub fn get_last_path_component<P: AsRef<Path>>(path: P) -> String
Expand description

Get the last component of a path (file or folder name).

§Arguments

§Returns

The last component of the path.

§Panics

If the last path component cannot be determined.

§Examples

§File path

use file_io::get_last_path_component;

let name = get_last_path_component("/some/path/to/file.txt");
assert_eq!(name, "file.txt");

§Folder path

use file_io::get_last_path_component;

let name = get_last_path_component("some/path/to/folder");
assert_eq!(name, "folder");