use path_rs::{
CaseNormalization, TextNormalizationOptions, normalize_path_token, path_to_string_lossy,
path_to_utf8,
};
use std::path::Path;
fn main() -> Result<(), path_rs::PathError> {
let opts = TextNormalizationOptions {
trim_whitespace: true,
trim_trailing_separators: true,
normalize_separators: true,
case: CaseNormalization::AsciiLowercase,
};
let token = normalize_path_token(r" Foo\Bar\ ", &opts);
println!("normalize_path_token => {token:?}");
let preserve = TextNormalizationOptions::new();
println!(
"default token => {:?}",
normalize_path_token("Repo/Name/", &preserve)
);
println!(
"UnicodeLowercase => {}",
CaseNormalization::UnicodeLowercase.apply("Straße")
);
let utf8 = path_to_utf8(Path::new("src/lib.rs"))?;
println!("path_to_utf8 => {utf8}");
let lossy = path_to_string_lossy(Path::new("src/lib.rs"));
println!("path_to_string_lossy => {lossy}");
#[cfg(feature = "unicode")]
{
use path_rs::logical_path_key;
let key = logical_path_key(Path::new("café/path"));
println!("logical_path_key => {key}");
}
Ok(())
}