diff options
| author | Matthias Krüger <matthias.krueger@famsik.de> | 2024-08-15 00:02:26 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-08-15 00:02:26 +0200 |
| commit | 6c242a0da44215a9c0273802da5148aff32eec2c (patch) | |
| tree | 58ec5c2e30c85eceb708aa9afd69b5a5f6da7b8c /src/tools | |
| parent | cd1b42c3e9a2f60c3fae428ef839514b7e97eb0e (diff) | |
| parent | 63ab7b59573a4e8d660b4c0235af6b8789c3753e (diff) | |
| download | rust-6c242a0da44215a9c0273802da5148aff32eec2c.tar.gz rust-6c242a0da44215a9c0273802da5148aff32eec2c.zip | |
Rollup merge of #128963 - GuillaumeGomez:output-to-stdout, r=aDotInTheVoid
Add possibility to generate rustdoc JSON output to stdout Fixes #127165. I think it's likely common to want to get rustdoc json output directly instead of reading it from a file so I added this option to allow it. It's unstable and only works with `--output-format=json`. r? `@aDotInTheVoid`
Diffstat (limited to 'src/tools')
| -rw-r--r-- | src/tools/run-make-support/src/path_helpers.rs | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/src/tools/run-make-support/src/path_helpers.rs b/src/tools/run-make-support/src/path_helpers.rs index b788bc6ef30..1e6e44c4584 100644 --- a/src/tools/run-make-support/src/path_helpers.rs +++ b/src/tools/run-make-support/src/path_helpers.rs @@ -84,3 +84,18 @@ pub fn has_suffix<P: AsRef<Path>>(path: P, suffix: &str) -> bool { pub fn filename_contains<P: AsRef<Path>>(path: P, needle: &str) -> bool { path.as_ref().file_name().is_some_and(|name| name.to_str().unwrap().contains(needle)) } + +/// Helper for reading entries in a given directory and its children. +pub fn read_dir_entries_recursive<P: AsRef<Path>, F: FnMut(&Path)>(dir: P, mut callback: F) { + fn read_dir_entries_recursive_inner<P: AsRef<Path>, F: FnMut(&Path)>(dir: P, callback: &mut F) { + for entry in rfs::read_dir(dir) { + let path = entry.unwrap().path(); + callback(&path); + if path.is_dir() { + read_dir_entries_recursive_inner(path, callback); + } + } + } + + read_dir_entries_recursive_inner(dir, &mut callback); +} |
