Skip to main content

display_path

Function display_path 

Source
pub fn display_path(path: &Path) -> String
Expand description

Render a filesystem path for user-facing output with forward slashes on every platform.

On Windows, Path::join appends the native \ separator, so a path built from a forward-slash input (such as a shell-glob argument like examples/foo) comes out mixed: examples/foo\bar.pdf. Normalizing to / keeps CLI output, diagnostics, and error messages consistent across platforms. On Unix the platform separator is already /, so this is a no-op.

ยงExamples

use std::path::Path;

use mos_core::display_path;

// Unchanged on Unix; on Windows any `\` separators become `/`.
assert_eq!(display_path(Path::new("a/b/c.pdf")), "a/b/c.pdf");