mirror of
https://github.com/xavo95/repak.git
synced 2025-02-22 15:53:45 +00:00
ParallelPakWriter can be moved into closure
This commit is contained in:
parent
194e800270
commit
5cfc8f52bd
1 changed files with 2 additions and 2 deletions
|
@ -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()
|
||||||
|
|
Loading…
Reference in a new issue