Skip to main content

normalize_slashes

Function normalize_slashes 

Source
pub fn normalize_slashes(path: &str) -> String
Expand description

Normalize path separators to /.

ยงExamples

use tokmd_path::normalize_slashes;

assert_eq!(normalize_slashes("src\\lib.rs"), "src/lib.rs");
assert_eq!(normalize_slashes("already/forward"), "already/forward");

Mixed separators are all converted:

use tokmd_path::normalize_slashes;

assert_eq!(normalize_slashes("a\\b/c\\d"), "a/b/c/d");
// Already-normalized paths pass through unchanged
assert_eq!(normalize_slashes("no/change"), "no/change");