ParallelPakWriter can be moved into closure

This commit is contained in:
Truman Kilen 2025-01-20 18:49:45 -06:00
parent 194e800270
commit 5cfc8f52bd

View file

@ -294,7 +294,7 @@ impl<W: Write + Seek> PakWriter<W> {
pub fn parallel<'scope, F, E>(&mut self, f: F) -> Result<&mut Self, E> pub fn parallel<'scope, F, E>(&mut self, f: F) -> Result<&mut Self, E>
where where
F: Send + Sync + FnOnce(&mut ParallelPakWriter<'scope>) -> Result<(), E>, F: Send + Sync + FnOnce(ParallelPakWriter<'scope>) -> Result<(), E>,
E: From<Error> + Send, E: From<Error> + Send,
{ {
use pariter::IteratorExt as _; use pariter::IteratorExt as _;
@ -303,7 +303,7 @@ impl<W: Write + Seek> PakWriter<W> {
pariter::scope(|scope: &pariter::Scope<'_>| -> Result<(), E> { pariter::scope(|scope: &pariter::Scope<'_>| -> Result<(), E> {
let (tx, rx) = std::sync::mpsc::sync_channel(0); let (tx, rx) = std::sync::mpsc::sync_channel(0);
let handle = scope.spawn(|_| f(&mut ParallelPakWriter { tx })); let handle = scope.spawn(|_| f(ParallelPakWriter { tx }));
let result = rx let result = rx
.into_iter() .into_iter()