Skip to main content

normalize_path_token

Function normalize_path_token 

Source
pub fn normalize_path_token(
    value: &str,
    options: &TextNormalizationOptions,
) -> String
Expand description

Normalize a path-like text token for comparison or matching.

§Filesystem access

No.

§Returns

A String suitable for comparison only — not necessarily a valid filesystem path.

§Examples

use path_rs::{normalize_path_token, CaseNormalization, TextNormalizationOptions};

let key = normalize_path_token(
    r"C:\Users\Floris\Repo\",
    &TextNormalizationOptions {
        trim_whitespace: true,
        trim_trailing_separators: true,
        normalize_separators: true,
        case: CaseNormalization::AsciiLowercase,
    },
);
assert_eq!(key, "c:/users/floris/repo");