`Digest` should be Copy
lightsing opened this issue · comments
Digest
should dervie Copy.
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
?
Can you use
std::mem::replace
?
fine with me. thx.