βGood enoughβ is a tough question. Both of them work to determine the path, because Windows treats slashes ( /) in the same way as backslashes ( \).
, - ( !), :
use std::path::Path;
fn main() {
let p = Path::new("target/debug");
println!("{}", p.exists());
println!("{}", p.display());
let p = Path::new("target").join("debug");
println!("{}", p.exists());
println!("{}", p.display());
}
true
target/debug
true
target\debug
, , :
fn main() {
let cwd = std::env::current_dir().expect("No CWD");
let p = cwd.join("target/debug");
println!("{}", p.exists());
println!("{}", p.display());
let p = cwd.join("target").join("debug");
println!("{}", p.exists());
println!("{}", p.display());
}
true
c:\Rust\dirs\target/debug
true
c:\Rust\dirs\target\debug