diff --git a/packer/src/main.rs b/packer/src/main.rs index 931dded15..ab69e2b37 100644 --- a/packer/src/main.rs +++ b/packer/src/main.rs @@ -42,8 +42,8 @@ fn pack( .get(platform) .ok_or_else(|| error::Error::MissingPlatformDefinition(platform.clone()))?; packtype_paths - .iter() - .try_fold(vec![], |mut acc, (pack_type, pack_files)| { + .into_iter() + .map(|(pack_type, pack_files)| { print!( "Packing for platform {:?} type {:?} ... ", platform, pack_type @@ -63,9 +63,9 @@ fn pack( tar.finish()?; println!("done."); - acc.push((*pack_type, output_path)); - Ok(acc) + Ok((*pack_type, output_path)) }) + .collect() } fn pack_platform( @@ -192,14 +192,23 @@ fn gen_manifest(archive_paths: &[(PackType, path::PathBuf)]) -> Result Result> { - archive_paths.into_iter().try_fold( - BTreeMap::new(), - |mut acc: BTreeMap, (pack_type, path)| { + let res = archive_paths + .into_iter() + .map(|(pack_type, path)| { let reader = BufReader::new(File::open(path)?); - acc.insert(*pack_type, sha256_digest(reader)?); - Ok(acc) - }, - ) + let hash = sha256_digest(reader)?; + Ok((*pack_type, hash)) + }) + .collect::>>()? + .into_iter() + .fold( + BTreeMap::new(), + |mut acc: BTreeMap, (pack_type, hash_sum)| { + acc.insert(pack_type, hash_sum); + acc + }, + ); + Ok(res) } #[cfg(test)]