Rust library to convert a file path from/to slash path
path-slash is a tiny library to convert a file path (e.g. foo/bar, foo\bar or
C:\\foo\bar) from/to slash path (e.g. foo/bar, C://foo/bar).
In Unix-like OS, path separator is slash / by default. So any conversion is not necessary. But on
Windows, file path separator \ needs to be replaced with slash / (and of course \ for escaping
character should not be replaced).
This package was inspired by Go's path/filepath.FromSlash
and path/filepath.ToSlash.
Usage
path_slash::PathExt and path_slash::PathBufExt traits are defined. By using them, std::path::Path
and std::path::PathBuf gains some methods and associated functions
PathExtPath::to_slash(&self) -> Option<String>Path::to_slash_lossy(&self) -> String
PathBufExtPathBuf::from_slash<S: AsRef<str>>(s: S) -> PathBufPathBuf::from_slash_lossy<S: AsRef<OsStr>>(s: S) -> PathBufPathBuf::to_slash(&self) -> Option<String>PathBuf::to_slash_lossy(&self) -> String
Please read documents for more details.
Installation
Add path-slash to dependencies:
[]
= "0.x"