I have to convert the PathBuf
variable to a String
to feed my function. My code is like this:
let cwd = env::current_dir().unwrap();
let my_str: String = cwd.as_os_str().to_str().unwrap().to_string();
println!("{:?}", my_str);
it works but is awful with the cwd.as_os_str…
.
Do you have a more convenient method or any suggestions on how to handle it?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…