1use ignore::WalkBuilder;
2use std::path::{Path, PathBuf};
3
4pub struct RustFileWalker {
5 builder: WalkBuilder,
6}
7
8impl RustFileWalker {
9 pub fn new() -> Self {
10 let mut builder = WalkBuilder::new(".");
11 builder
12 .standard_filters(true)
13 .add_custom_ignore_filename(".flignore");
14
15 Self { builder }
16 }
17
18 pub fn walk(&self, path: &Path) -> impl Iterator<Item = PathBuf> {
19 let mut builder = WalkBuilder::new(path);
20 builder
21 .standard_filters(true)
22 .add_custom_ignore_filename(".flignore");
23
24 builder.build()
25 .filter_map(|entry| entry.ok())
26 .filter(|entry| {
27 entry.path().extension()
28 .map_or(false, |ext| ext == "rs")
29 })
30 .map(|entry| entry.path().to_path_buf())
31 }
32}