Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
rust 不同系统转换目录路径
pub fn convert_path(path_str: &str) -> String {
if cfg!(target_os = "windows") {
String::from(path_str.replace("\\", "/"))
} else {
fn main() {
println!("hello world!");
let test_path = String::from("C:\\windows\\system32\\cmd.exe");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.