[go: up one dir, main page]

get_filename

Function get_filename 

Source
pub fn get_filename(file: &Path) -> Option<&str>
Expand description

Extracts the filename component from the given file path and returns it as an Option<&str>.

If the file path contains a filename, this function returns Some(filename) where filename is the extracted filename as a string slice (&str). If the file path does not have a filename component or if the filename is not valid UTF-8, it returns None.

§Arguments

  • file: A reference to a Path representing the file path from which to extract the filename.

§Returns

  • Some(filename): If a valid filename exists in the file path, where filename is the extracted filename as a string slice (&str).
  • None: If the file path does not contain a valid filename or if the filename is not valid UTF-8.