diff options
| author | Josh Stone <jistone@redhat.com> | 2024-06-05 13:20:17 -0700 |
|---|---|---|
| committer | Josh Stone <jistone@redhat.com> | 2024-06-05 13:20:17 -0700 |
| commit | c0e25431478a0b621310b514022ccfae3dee1974 (patch) | |
| tree | 47fe3c476788e27d3b9a9481db841a66bd323f48 /src/tools | |
| parent | db8aca48129d86b2623e3ac8cbcf2902d4d313ad (diff) | |
Simplify the rayon calls in the installer
Rayon's `try_for_each` makes the `CombinedEncoder` a lot simpler.
Diffstat (limited to 'src/tools')
| -rw-r--r-- | src/tools/rust-installer/src/compression.rs | 12 |
1 files changed, 3 insertions, 9 deletions
diff --git a/src/tools/rust-installer/src/compression.rs b/src/tools/rust-installer/src/compression.rs index 4e840dbfbb4..40c7c597e9b 100644 --- a/src/tools/rust-installer/src/compression.rs +++ b/src/tools/rust-installer/src/compression.rs @@ -214,22 +214,16 @@ impl Write for CombinedEncoder { } fn write_all(&mut self, buf: &[u8]) -> std::io::Result<()> { - self.encoders - .par_iter_mut() - .map(|w| w.write_all(buf)) - .collect::<std::io::Result<Vec<()>>>()?; - Ok(()) + self.encoders.par_iter_mut().try_for_each(|w| w.write_all(buf)) } fn flush(&mut self) -> std::io::Result<()> { - self.encoders.par_iter_mut().map(|w| w.flush()).collect::<std::io::Result<Vec<()>>>()?; - Ok(()) + self.encoders.par_iter_mut().try_for_each(Write::flush) } } impl Encoder for CombinedEncoder { fn finish(self: Box<Self>) -> Result<(), Error> { - self.encoders.into_par_iter().map(|e| e.finish()).collect::<Result<Vec<()>, Error>>()?; - Ok(()) + self.encoders.into_par_iter().try_for_each(Encoder::finish) } } |
