Require boxing?.

This commit is contained in:
Tom Alexander 2024-10-18 21:19:40 -04:00
parent 5d3a6c4174
commit 98fa43575d
Signed by: talexander
GPG Key ID: D3A179C9A53C0EDE
2 changed files with 5 additions and 5 deletions

View File

@ -61,7 +61,7 @@ async fn get_output_directory(config: &Config) -> Result<PathBuf, CustomError> {
Ok(output_directory) Ok(output_directory)
} }
async fn filter_to_post_directories(entry: &DirEntry) -> Result<bool, CustomError> { fn filter_to_post_directories(entry: &DirEntry) -> Result<bool, CustomError> {
Ok(true) Ok(true)
} }

View File

@ -5,19 +5,19 @@ use tokio::fs::DirEntry;
use crate::error::CustomError; use crate::error::CustomError;
pub(crate) async fn walk_fs<P: AsRef<Path>, F: AsyncFn(&DirEntry) -> Result<bool, CustomError>>( pub(crate) async fn walk_fs<P: AsRef<Path>>(
root: P, root: P,
predicate: F, predicate: fn(&DirEntry) -> Result<bool, CustomError>,
) -> Result<Vec<DirEntry>, CustomError> { ) -> Result<Vec<DirEntry>, CustomError> {
let mut ret = Vec::new(); let mut ret = Vec::new();
let mut entries = tokio::fs::read_dir(root).await?; let mut entries = tokio::fs::read_dir(root).await?;
while let Some(entry) = entries.next_entry().await? { while let Some(entry) = entries.next_entry().await? {
let file_type = entry.file_type().await?; let file_type = entry.file_type().await?;
if file_type.is_dir() { if file_type.is_dir() {
let child_entries = walk_fs(entry.path(), &predicate).await?; let child_entries = walk_fs(entry.path(), predicate).await?;
ret.extend(child_entries); ret.extend(child_entries);
} }
if predicate(&entry).await? { if predicate(&entry)? {
ret.push(entry); ret.push(entry);
} }
} }