diff --git a/rust/matrix2mqtt/src/main.rs b/rust/matrix2mqtt/src/main.rs index 1b69bee7d7..bd1b9ba008 100644 --- a/rust/matrix2mqtt/src/main.rs +++ b/rust/matrix2mqtt/src/main.rs @@ -171,7 +171,7 @@ async fn read_single_mapping( reader.read_line(&mut line).await?; let splitter = line .strip_prefix("MP ") - .and_then(|s| Some(s.split_whitespace())) + .map(|s| s.split_whitespace()) .ok_or(ParseMatrixPortError)? .collect::>(); if splitter.len() != 2 { @@ -287,16 +287,16 @@ async fn handle_publish( matrix_command_tx .send(MatrixCommand::SetOutputCEC(destination, true)) .await?; - }, + } "OFF" => { println!("asked to turn {:#?} off", destination); matrix_command_tx .send(MatrixCommand::SetOutputCEC(destination, false)) .await?; - }, + } s => { println!("asked to set {:#?} to unknown value {}", destination, s) - }, + } } } else if let Some(destination_str) = p .topic @@ -363,7 +363,7 @@ async fn publish_config( ) .await?; - client + client .publish( format!( "homeassistant/switch/matrix_{}_cec/config", @@ -400,7 +400,7 @@ where I: futures::Future> + Unpin, { let mut fvec = futures; - while fvec.len() > 0 { + while !fvec.is_empty() { let (item_resolved, _, remaining_futures) = future::select_all(fvec).await; item_resolved?; fvec = remaining_futures; @@ -441,14 +441,11 @@ async fn main() -> Result<(), Box> { loop { select! { notification = connection.poll() => { - match notification? { - rumqttc::Event::Incoming(rumqttc::Incoming::Publish(p)) => { - match handle_publish(&p, &mut mqtt_matrix_command_tx).await { - Ok(_) => {}, - Err(e) => println!("failed to handle event {:#?}: {}", p, e), - } - }, - _ => {}, + if let rumqttc::Event::Incoming(rumqttc::Incoming::Publish(p)) = notification? { + match handle_publish(&p, &mut mqtt_matrix_command_tx).await { + Ok(_) => {}, + Err(e) => println!("failed to handle event {:#?}: {}", p, e), + } } }, Ok(matrix_response) = matrix_response_rx.recv() => {