Future is not send.

This commit is contained in:
Tom Alexander 2024-10-18 21:29:15 -04:00
parent 8868cfb63f
commit b6cc7a70b7
Signed by: talexander
GPG Key ID: D3A179C9A53C0EDE
2 changed files with 7 additions and 3 deletions

View File

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

View File

@ -1,3 +1,4 @@
use std::future::Future;
use std::ops::AsyncFn; use std::ops::AsyncFn;
use std::path::Path; use std::path::Path;
@ -9,7 +10,10 @@ use crate::error::CustomError;
pub(crate) fn walk_fs<'p, P: AsRef<Path> + std::marker::Send + 'p>( pub(crate) fn walk_fs<'p, P: AsRef<Path> + std::marker::Send + 'p>(
root: P, root: P,
predicate: fn(&DirEntry) -> Result<bool, CustomError>, predicate: impl AsyncFn(&DirEntry) -> Result<bool, CustomError>
+ std::marker::Send
+ 'p
+ std::marker::Copy,
) -> BoxFuture<'p, Result<Vec<DirEntry>, CustomError>> { ) -> BoxFuture<'p, Result<Vec<DirEntry>, CustomError>> {
async move { async move {
let mut ret = Vec::new(); let mut ret = Vec::new();
@ -20,7 +24,7 @@ pub(crate) fn walk_fs<'p, P: AsRef<Path> + std::marker::Send + 'p>(
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)? { if predicate(&entry).await? {
ret.push(entry); ret.push(entry);
} }
} }