Closed lightsing closed 1 year ago
Digest should dervie Copy.
Digest
Usage:
struct ChunkedWriter<I, W> { crc: Digest<'static, I>, writer: W, } impl<I: Implementation, W: io::Write> io::Write for ChunkedWriter<I, W> { fn write(&mut self, mut buf: &[u8]) -> io::Result<usize> { // some other codes... end of a chunk let checksum = self.crc.finalize().to_be_bytes(); // <- cannot move out from a mutable reference self.writer.write_all(&checksum)?; self.crc = CRC.digest(); // other... } }
Can you use std::mem::replace?
std::mem::replace
fine with me. thx.
Digest
should dervie Copy.Usage: