From 7bf5962554ecc14401d70b9c2a47ff1356f7bbf0 Mon Sep 17 00:00:00 2001 From: Pascal Seitz Date: Thu, 16 Jun 2022 16:50:56 +0800 Subject: [PATCH] merge match, explicit type --- src/store/writer.rs | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/src/store/writer.rs b/src/store/writer.rs index 140dd08a7..f68fce831 100644 --- a/src/store/writer.rs +++ b/src/store/writer.rs @@ -56,9 +56,13 @@ impl StoreWriter { let thread_builder = thread::Builder::new().name("docstore compressor thread".to_string()); // Data channel to send fs writes, to write only from current thread - let (data_sender, data_receiver) = sync_channel(3); + let (data_sender, data_receiver): (SyncSender, Receiver) = + sync_channel(3); // Channel to send uncompressed data to compressor channel - let (block_sender, block_receiver) = sync_channel(3); + let (block_sender, block_receiver): ( + SyncSender, + Receiver, + ) = sync_channel(3); let thread_join_handle = thread_builder.spawn(move || { let mut block_compressor = BlockCompressor::new(compressor, data_sender); while let Ok(packet) = block_receiver.recv() { @@ -116,17 +120,15 @@ impl StoreWriter { Ok(data) => { self.writer.write_all(data.as_slice())?; } - Err(err) => match err { - TryRecvError::Empty => { - break; - } - TryRecvError::Disconnected => { - return Err(io::Error::new( - io::ErrorKind::Other, - "compressor data channel unexpected closed".to_string(), - )); - } - }, + Err(TryRecvError::Empty) => { + break; + } + Err(TryRecvError::Disconnected) => { + return Err(io::Error::new( + io::ErrorKind::Other, + "compressor data channel unexpected closed".to_string(), + )); + } } }