ext

Function ext 

Source
pub fn ext(path: impl AsRef<Path>) -> String
Expand description

Extracts the extension from the given path.

This function takes a path and returns a string representing the extension of the file. If the input path is empty or if it doesn’t contain an extension, it returns an empty string.

§Arguments

  • path - An object that can be converted into a Path reference, representing the file path.

§Returns

A string containing the extension of the file, or an empty string if the input path is empty or lacks an extension.

§Examples

use proper_path_tools::path::ext;

let path = "/path/to/file.txt";
let extension = ext( path );
assert_eq!( extension, "txt" );
use proper_path_tools::path::ext;

let empty_path = "";
let extension = ext( empty_path );
assert_eq!( extension, "" );