Skip to content

Commit 79d59f8

Browse files
committed
Cargo clippy fix
1 parent af826de commit 79d59f8

3 files changed

Lines changed: 10 additions & 14 deletions

File tree

src/main.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -139,11 +139,10 @@ async fn main() -> Result<()> {
139139
let shutdown_tx = shutdown_tx.clone();
140140
ctrlc::set_handler(move || {
141141
running.store(false, Ordering::SeqCst);
142-
if let Ok(tx_guard) = shutdown_tx.lock() {
143-
if let Some(tx) = tx_guard.as_ref() {
142+
if let Ok(tx_guard) = shutdown_tx.lock()
143+
&& let Some(tx) = tx_guard.as_ref() {
144144
let _ = tx.send(UiMessage::Quit);
145145
}
146-
}
147146
})
148147
.expect("Failed to set Ctrl-C handler");
149148
}

src/serial_io.rs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ impl SerialReader {
8484
let mut hex_str = String::with_capacity(capacity);
8585

8686
if self.log_ts {
87-
hex_str.push_str("[");
87+
hex_str.push('[');
8888
hex_str.push_str(&Utc::now().format("%Y-%m-%d %H:%M:%S%.3f").to_string());
8989
hex_str.push_str("] ");
9090
}
@@ -105,7 +105,7 @@ impl SerialReader {
105105
let mut text = String::with_capacity(capacity);
106106

107107
if self.log_ts {
108-
text.push_str("[");
108+
text.push('[');
109109
text.push_str(&Utc::now().format("%Y-%m-%d %H:%M:%S%.3f").to_string());
110110
text.push_str("] ");
111111
}
@@ -116,8 +116,8 @@ impl SerialReader {
116116
}
117117

118118
async fn write_to_log(&mut self, bytes: &[u8]) {
119-
if let Some(w) = &self.rx_log_writer {
120-
if let Ok(mut lw) = w.lock() {
119+
if let Some(w) = &self.rx_log_writer
120+
&& let Ok(mut lw) = w.lock() {
121121
use std::io::Write;
122122

123123
if self.log_ts {
@@ -136,7 +136,6 @@ impl SerialReader {
136136

137137
let _ = lw.flush();
138138
}
139-
}
140139
}
141140
}
142141

src/ui/mod.rs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -144,32 +144,30 @@ async fn handle_enter_key(
144144
// Send the complete line to serial port
145145
if !input.is_empty() {
146146
write_bytes_async(port, input.as_bytes()).await?;
147-
if let Some(w) = &ui_config.tx_log {
148-
if let Ok(mut lw) = w.lock() {
147+
if let Some(w) = &ui_config.tx_log
148+
&& let Ok(mut lw) = w.lock() {
149149
use std::io::Write;
150150
if ui_config.log_ts {
151151
let _ = write!(lw, "[{}] ", Utc::now().format("%Y-%m-%d %H:%M:%S%.3f"));
152152
}
153153
let _ = lw.write_all(input.as_bytes());
154154
let _ = lw.flush();
155155
}
156-
}
157156
}
158157

159158
// Send line ending
160159
let end = ui_config.line_ending.bytes();
161160
if !end.is_empty() {
162161
write_bytes_async(port, end).await?;
163-
if let Some(w) = &ui_config.tx_log {
164-
if let Ok(mut lw) = w.lock() {
162+
if let Some(w) = &ui_config.tx_log
163+
&& let Ok(mut lw) = w.lock() {
165164
use std::io::Write;
166165
if ui_config.log_ts && input.is_empty() {
167166
let _ = write!(lw, "[{}] ", Utc::now().format("%Y-%m-%d %H:%M:%S%.3f"));
168167
}
169168
let _ = lw.write_all(end);
170169
let _ = lw.flush();
171170
}
172-
}
173171
}
174172

175173
Ok(())

0 commit comments

Comments
 (0)