simple_fs/list/
iter_dirs.rs

1use crate::{ListOptions, Result, SPath};
2
3use std::path::Path;
4
5/// Returns an iterator over directories in the specified `dir` filtered optionally by `include_globs`
6/// and `list_options`. This implementation uses the internal GlobsDirIter.
7pub fn iter_dirs(
8	dir: impl AsRef<Path>,
9	include_globs: Option<&[&str]>,
10	list_options: Option<ListOptions<'_>>,
11) -> Result<impl Iterator<Item = SPath>> {
12	let iter = super::globs_dir_iter::GlobsDirIter::new(dir, include_globs, list_options)?;
13	Ok(iter)
14}
15
16/// Collects directories from `iter_dirs` into a Vec<SPath>
17pub fn list_dirs(
18	dir: impl AsRef<Path>,
19	include_globs: Option<&[&str]>,
20	list_options: Option<ListOptions<'_>>,
21) -> Result<Vec<SPath>> {
22	let iter = iter_dirs(dir, include_globs, list_options)?;
23	Ok(iter.collect())
24}