Function get_file_extension

Source
pub fn get_file_extension(path: &str) -> Option<String>
Expand description

Extract the file extension from a file path

This function extracts the file extension from a given path and returns it in lowercase. This is useful for language detection and file filtering.

§Arguments

  • path - The file path to extract the extension from

§Returns

Some(String) containing the lowercase extension if present, None otherwise.

§Examples

use tree_parser::get_file_extension;
 
assert_eq!(get_file_extension("test.py"), Some("py".to_string()));
assert_eq!(get_file_extension("test.RS"), Some("rs".to_string()));
assert_eq!(get_file_extension("test"), None);
assert_eq!(get_file_extension("path/to/file.js"), Some("js".to_string()));