Use a type alias for read file results.
This commit is contained in:
parent
379850fe3d
commit
7ddc4011b3
@ -263,9 +263,11 @@ fn build_name_contents_pairs<'a>(
|
|||||||
Ok((name, contents))
|
Ok((name, contents))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type ReadFileResult = std::io::Result<(PathBuf, Vec<u8>)>;
|
||||||
|
|
||||||
fn get_all_files<P: AsRef<Path>>(
|
fn get_all_files<P: AsRef<Path>>(
|
||||||
root_dir: P,
|
root_dir: P,
|
||||||
) -> Result<impl Iterator<Item = JoinHandle<std::io::Result<(PathBuf, Vec<u8>)>>>, walkdir::Error> {
|
) -> Result<impl Iterator<Item = JoinHandle<ReadFileResult>>, walkdir::Error> {
|
||||||
let files = WalkDir::new(root_dir)
|
let files = WalkDir::new(root_dir)
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.filter(|e| match e {
|
.filter(|e| match e {
|
||||||
@ -280,7 +282,7 @@ fn get_all_files<P: AsRef<Path>>(
|
|||||||
Ok(org_files)
|
Ok(org_files)
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn read_file(path: PathBuf) -> std::io::Result<(PathBuf, Vec<u8>)> {
|
async fn read_file(path: PathBuf) -> ReadFileResult {
|
||||||
let contents = tokio::fs::read(&path).await?;
|
let contents = tokio::fs::read(&path).await?;
|
||||||
Ok((path, contents))
|
Ok((path, contents))
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user