Skip to content

Commit

Permalink
Clippy auto fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
haimgel committed Oct 29, 2023
1 parent e13c471 commit 727c70f
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 12 deletions.
4 changes: 2 additions & 2 deletions src/configuration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,8 @@ impl InputSources {

pub fn execute_command(&self, direction: SwitchDirection) -> Option<&str> {
match direction {
SwitchDirection::Connect => self.on_usb_connect_execute.as_ref().map(|x| &**x),
SwitchDirection::Disconnect => self.on_usb_disconnect_execute.as_ref().map(|x| &**x),
SwitchDirection::Connect => self.on_usb_connect_execute.as_deref(),
SwitchDirection::Disconnect => self.on_usb_disconnect_execute.as_deref(),
}
}
}
Expand Down
12 changes: 6 additions & 6 deletions src/display_control.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use crate::input_source::InputSource;

use anyhow::{Error, Result};
use ddc_hi::{Ddc, Display, Handle};
use shell_words;

use std::collections::HashSet;
use std::process::{Command, Stdio};
use std::{thread, time};
Expand Down Expand Up @@ -85,7 +85,7 @@ fn displays() -> Vec<Display> {
delay_duration.as_secs()
);
thread::sleep(delay_duration);
return Display::enumerate();
Display::enumerate()
}

pub fn log_current_source() {
Expand Down Expand Up @@ -146,7 +146,7 @@ fn run_command(execute_command: &str) {

let executable = arguments.remove(0);
let output = Command::new(executable).args(arguments).stdin(Stdio::null()).output()?;
return if output.status.success() {
if output.status.success() {
info!("External command '{}' executed successfully", execute_command);
Ok(())
} else {
Expand All @@ -159,7 +159,7 @@ fn run_command(execute_command: &str) {
if let Ok(s) = String::from_utf8(output.stdout) {
format!("Stdout = [{}]\n", s)
} else {
format!("Stdout was not UTF-8")
"Stdout was not UTF-8".to_string()
}
} else {
"No stdout\n".to_string()
Expand All @@ -168,13 +168,13 @@ fn run_command(execute_command: &str) {
if let Ok(s) = String::from_utf8(output.stderr) {
format!("Stderr = [{}]\n", s)
} else {
format!("Stderr was not UTF-8")
"Stderr was not UTF-8".to_string()
}
} else {
"No stderr\n".to_string()
};
Err(Error::msg(format!("{} {} {}", msg, stdout, stderr)))
};
}
}

try_run_command(execute_command)
Expand Down
6 changes: 3 additions & 3 deletions src/input_source.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,9 +101,9 @@ impl<'de> Deserialize<'de> for InputSource {
}
}

impl Into<u16> for InputSource {
fn into(self) -> u16 {
self.value()
impl From<InputSource> for u16 {
fn from(val: InputSource) -> Self {
val.value()
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/platform/wake_displays.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ pub fn wake_displays() -> Result<()> {
use anyhow::anyhow;
use std::process::Command;

match Command::new("/usr/bin/caffeinate").args(&["-u", "-t", "10"]).status() {
match Command::new("/usr/bin/caffeinate").args(["-u", "-t", "10"]).status() {
Ok(status) => {
if status.success() {
Ok(())
Expand Down

0 comments on commit 727c70f

Please sign in to comment.