私はそうのような 、機能するようにディレクトリ名のリストを渡したい:関数へのパスのリストを渡すには?
use std::path::Path;
fn test(dirs: &Vec<Path>) {}
fn main() {
let dirs = vec![Path::new("/tmp"), Path::new("/var/tmp")];
test(dirs);
}
しかし、それはコンパイルされません:
<anon>:3:5: 4:6 error: the trait bound `[u8]: std::marker::Sized` is not satisfied [E0277]
<anon>:3 fn test(dirs: &Vec<Path>) {
<anon>:4 }
<anon>:3:5: 4:6 help: see the detailed explanation for E0277
<anon>:3:5: 4:6 note: `[u8]` does not have a constant size known at compile-time
<anon>:3:5: 4:6 note: required because it appears within the type `std::sys::os_str::Slice`
<anon>:3:5: 4:6 note: required because it appears within the type `std::ffi::OsStr`
<anon>:3:5: 4:6 note: required because it appears within the type `std::path::Path`
<anon>:3:5: 4:6 note: required by `std::vec::Vec`
はパスではありませんSized
ように見えますか?
Vec<String>
を機能させるにはどうすればいいですか? PathBuf
?どのようにこれを錆びた方法で実装するのですか?
https://doc.rust-lang.org/std/path/struct.PathBuf.html –