Function get_file_extension

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

Get the file extension.

§Arguments

  • path - The path to the file (can be a &str, String, Path, or PathBuf).

§Returns

The file extension. If the file has no extension, or if the extension cannot be determined, this function returns an empty string.

§Example

use file_io::get_file_extension;

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