Я пытаюсь использовать ignore crate с методом параллельной сборки. Я использовал пример документации:
WalkBuilder::new("./").build_parallel().run(|| |path| println!("{:?}", path));
, но я получаю ошибку:
= note: expected struct `std::boxed::Box<dyn std::ops::FnMut(std::result::Result<ignore::walk::DirEntry, ignore::Error>) -> ignore::walk::WalkState + std::marker::Send>`
found closure `[closure@src/main.rs:4:52: 4:81]`
= note: for more on the distinction between the stack and the heap, read https://doc.rust-lang.org/book/ch15-01-box.html, https://doc.rust-lang.org/rust-by-example/std/box.html, and https://doc.rust-lang.org/std/boxed/index.html --> src/main.rs:4:52
|
4 | WalkBuilder::new("./").build_parallel().run(|| |path| println!("{:?}", path));
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
| |
| expected struct `std::boxed::Box`, found closure
| help: store this in the heap by calling `Box::new`: `Box::new(|path| println!("{:?}", path))`
|
= note: expected struct `std::boxed::Box<dyn std::ops::FnMut(std::result::Result<ignore::walk::DirEntry, ignore::Error>) -> ignore::walk::WalkState + std::marker::Send>`
found closure `[closure@src/main.rs:4:52: 4:81]`
= note: for more on the distinction between the stack and the heap, read https://doc.rust-lang.org/book/ch15-01-box.html, https://doc.rust-lang.org/rust-by-example/std/box.html, and https://doc.rust-lang.org/std/boxed/index.html
Я не понимаю замыкания в функции run
. Почему это не может быть просто
WalkBuilder::new("./").build_parallel().run(|path| println!("{:?}", path));
Почему должен быть ||
перед |path|
?