我应该如何在Rust中打印路径?
我尝试了以下代码以打印当前工作目录:
use std::os;
fn main() {
let p = os::getcwd();
println!("{}", p);
}
但是rustc
返回以下错误:
[wei2912@localhost rust-basics]$ rustc ls.rs
ls.rs:5:17: 5:18 error: failed to find an implementation of trait core::fmt::Show for std::path::posix::Path
ls.rs:5 println!("{}", p);
^
note: in expansion of format_args!
<std macros>:2:23: 2:77 note: expansion site
<std macros>:1:1: 3:2 note: in expansion of println!
ls.rs:5:2: 5:20 note: expansion site