diff --git a/src/calculator.rs b/src/calculator.rs index 6012028..8827e4c 100644 --- a/src/calculator.rs +++ b/src/calculator.rs @@ -19,16 +19,16 @@ pub enum Expr { Number(f64), Unary { op: UnaryOp, - rhs: Box, + rhs: Box, }, Binary { op: BinOp, - lhs: Box, - rhs: Box, + lhs: Box, + rhs: Box, }, Func { name: String, - args: Vec, + args: Vec, }, } @@ -52,9 +52,9 @@ impl Expr { use BinOp::*; use UnaryOp::*; match self { - Expr::Number(x) => Some(*x), + Self::Number(x) => Some(*x), - Expr::Unary { op, rhs } => { + Self::Unary { op, rhs } => { let v = rhs.eval()?; Some(match op { Plus => v, @@ -62,7 +62,7 @@ impl Expr { }) } - Expr::Binary { op, lhs, rhs } => { + Self::Binary { op, lhs, rhs } => { let a = lhs.eval()?; let b = rhs.eval()?; match op { @@ -74,7 +74,7 @@ impl Expr { } } - Expr::Func { name, args } => { + Self::Func { name, args } => { let name = name.as_str(); match name { "ln" => { diff --git a/src/clipboard.rs b/src/clipboard.rs index 979432e..e65d598 100644 --- a/src/clipboard.rs +++ b/src/clipboard.rs @@ -15,8 +15,8 @@ impl ClipBoardContentType { /// display name is only the first line pub fn to_app(&self) -> App { let mut name = match self { - ClipBoardContentType::Image(_) => "".to_string(), - ClipBoardContentType::Text(a) => a.to_owned(), + Self::Image(_) => "".to_string(), + Self::Text(a) => a.to_owned(), }; let self_clone = self.clone(); diff --git a/src/commands.rs b/src/commands.rs index bfffee1..d79a1ea 100644 --- a/src/commands.rs +++ b/src/commands.rs @@ -26,7 +26,7 @@ impl Function { /// Run the command pub fn execute(&self, config: &Config, query: &str) { match self { - Function::OpenApp(path) => { + Self::OpenApp(path) => { let path = path.to_owned(); thread::spawn(move || { NSWorkspace::new().openURL(&NSURL::fileURLWithPath( @@ -34,7 +34,7 @@ impl Function { )); }); } - Function::RunShellCommand(command, alias) => { + Self::RunShellCommand(command, alias) => { let query = query.to_string(); let final_command = format!(r#"{} {}"#, command, query.strip_prefix(alias).unwrap_or("")); @@ -44,14 +44,14 @@ impl Function { .spawn() .ok(); } - Function::RandomVar(var) => { + Self::RandomVar(var) => { Clipboard::new() .unwrap() .set_text(var.to_string()) .unwrap_or(()); } - Function::GoogleSearch(query_string) => { + Self::GoogleSearch(query_string) => { let query_args = query_string.replace(" ", "+"); let query = config.search_url.replace("%s", &query_args); let query = query.strip_suffix("?").unwrap_or(&query).to_string(); @@ -66,7 +66,7 @@ impl Function { }); } - Function::OpenWebsite(url) => { + Self::OpenWebsite(url) => { let open = if url.starts_with("http") { url.to_owned() } else { @@ -83,14 +83,14 @@ impl Function { }); } - Function::Calculate(expr) => { + Self::Calculate(expr) => { Clipboard::new() .unwrap() .set_text(expr.eval().map(|x| x.to_string()).unwrap_or("".to_string())) .unwrap_or(()); } - Function::CopyToClipboard(clipboard_content) => match clipboard_content { + Self::CopyToClipboard(clipboard_content) => match clipboard_content { ClipBoardContentType::Text(text) => { Clipboard::new().unwrap().set_text(text).ok(); } @@ -99,7 +99,7 @@ impl Function { } }, - Function::OpenPrefPane => { + Self::OpenPrefPane => { thread::spawn(move || { NSWorkspace::new().openURL(&NSURL::fileURLWithPath( &objc2_foundation::NSString::from_str( @@ -109,7 +109,7 @@ impl Function { )); }); } - Function::Quit => std::process::exit(0), + Self::Quit => std::process::exit(0), } } } diff --git a/src/haptics.rs b/src/haptics.rs index 50ee2f8..c1127c3 100644 --- a/src/haptics.rs +++ b/src/haptics.rs @@ -152,19 +152,18 @@ fn mts_state() -> Option<&'static MtsState> { /// Perform a haptic feedback - Just use this function to perform haptic feedback... please don't /// remake this function unless you're a genius or absolutely have to pub fn perform_haptic(pattern: HapticPattern) -> bool { - if let Some(state) = mts_state() { - let pat = pattern_index(pattern); - let mut any_ok = false; - unsafe { - for &act in &state.actuators { - if !act.is_null() && MTActuatorIsOpen(act) { - let kr = MTActuatorActuate(act, pat, 0, 0.0, 0.0); - any_ok |= kr == 0; - } + let Some(state) = mts_state() else { + return false; + }; + let pat = pattern_index(pattern); + let mut any_ok = false; + unsafe { + for &act in &state.actuators { + if !act.is_null() && MTActuatorIsOpen(act) { + let kr = MTActuatorActuate(act, pat, 0, 0.0, 0.0); + any_ok |= kr == 0; } } - any_ok - } else { - false } + any_ok }