Skip to content

Commit

Permalink
fix: clippy errors
Browse files Browse the repository at this point in the history
  • Loading branch information
Sequal32 committed May 9, 2023
1 parent 07e3c9e commit f04a8a1
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 15 deletions.
10 changes: 4 additions & 6 deletions src/yourcontrols-hoster/src/hoster/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,10 @@ impl ServerState {
}

pub fn get_from_addr(&mut self, addr: SocketAddr) -> Option<&mut ClientConnection> {
for (_, client) in self.clients.iter_mut() {
if client.addr == addr {
return Some(client);
}
}
None
self.clients
.iter_mut()
.map(|(_, client)| client)
.find(|client| client.addr == addr)
}

pub fn add_client(&mut self, name: String, addr: SocketAddr, is_observer: bool) {
Expand Down
6 changes: 1 addition & 5 deletions src/yourcontrols/src/clientmanager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ impl ClientManager {

if let Some(next_control) = self.next_control.as_ref() {
if next_control == name {
self.next_control = self.clients.keys().into_iter().next().cloned();
self.next_control = self.clients.keys().next().cloned();
}
}
}
Expand Down Expand Up @@ -100,8 +100,4 @@ impl ClientManager {
self.clients.clear();
self.current_control = None;
}

pub fn get_number_clients(&self) -> usize {
self.clients.len()
}
}
3 changes: 1 addition & 2 deletions src/yourcontrols/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#![cfg_attr(not(debug_assertions), windows_subsystem = "windows")]
#![allow(unaligned_references)]

mod app;
mod clientmanager;
Expand Down Expand Up @@ -46,7 +45,7 @@ const LOOP_SLEEP_TIME: Duration = Duration::from_millis(10);
fn get_aircraft_configs() -> io::Result<Vec<String>> {
let mut filenames = Vec::new();

for file in read_dir(&AIRCRAFT_DEFINITIONS_PATH)? {
for file in read_dir(AIRCRAFT_DEFINITIONS_PATH)? {
let file = file?;
filenames.push(
file.path()
Expand Down
4 changes: 2 additions & 2 deletions src/yourcontrols/src/sync/gaugecommunicator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,9 @@ pub enum InterpolationType {

fn format_get(var_name: &str, var_units: Option<&str>) -> String {
if let Some(unit) = var_units {
return format!(r#"({}, {})"#, var_name, unit.trim());
format!(r#"({}, {})"#, var_name, unit.trim())
} else {
return format!(r#"({})"#, var_name.trim());
format!(r#"({})"#, var_name.trim())
}
}

Expand Down

0 comments on commit f04a8a1

Please sign in to comment.