pub fn without_ext(path: impl AsRef<Path>) -> Option<PathBuf>Expand description
Extracts the parent directory and file stem (without extension) from the given path.
This function takes a path and returns an Option containing the modified path without the extension. If the input path is empty or if it doesn’t contain a file stem, it returns None.
§Arguments
path- An object that can be converted into a Path reference, representing the file path.
§Returns
An Option containing the modified path without the extension, or None if the input path is empty or lacks a file stem.
§Examples
use std ::path ::PathBuf;
use pth ::path ::without_ext;
let path = "/path/to/file.txt";
let modified_path = without_ext(path);
assert_eq!(modified_path, Some(PathBuf ::from("/path/to/file")));use std ::path ::PathBuf;
use pth ::path ::without_ext;
let empty_path = "";
let modified_path = without_ext(empty_path);
assert_eq!(modified_path, None);