From d811f60b008874a4645faafbb4c6fea3389d5667 Mon Sep 17 00:00:00 2001 From: Louis-Marie Baer Date: Tue, 27 Feb 2024 05:08:14 +0100 Subject: [PATCH] feat: cargo clippy --- src/constants.rs | 2 +- src/disk.rs | 6 +++--- src/gupax.rs | 7 +++---- src/helper.rs | 4 ++-- src/main.rs | 24 +++++++++--------------- src/node.rs | 4 ++-- src/p2pool.rs | 2 +- src/regex.rs | 6 +++--- src/status.rs | 3 +-- src/xmrig.rs | 2 +- 10 files changed, 26 insertions(+), 34 deletions(-) diff --git a/src/constants.rs b/src/constants.rs index 0429363..3fda878 100644 --- a/src/constants.rs +++ b/src/constants.rs @@ -411,7 +411,7 @@ For more information, see link below: //---------------------------------------------------------------------------------------------------- Visuals use egui::epaint::{Rounding, Shadow, Stroke}; -use egui::{style::Spacing, Color32, Visuals}; +use egui::{Color32, Visuals}; use egui::style::{Selection, WidgetVisuals, Widgets}; use once_cell::sync::Lazy; diff --git a/src/disk.rs b/src/disk.rs index f16bbf9..7128e46 100644 --- a/src/disk.rs +++ b/src/disk.rs @@ -817,13 +817,13 @@ impl GupaxP2poolApi { "GupaxP2poolApi | Deleting old folder at [{}]...", path.display() ); - std::fs::remove_dir_all(&path)?; + std::fs::remove_dir_all(path)?; info!( "GupaxP2poolApi | Creating new default folder at [{}]...", path.display() ); - create_gupax_p2pool_dir(&path)?; - Self::create_all_files(&path)?; + create_gupax_p2pool_dir(path)?; + Self::create_all_files(path)?; Ok(()) } diff --git a/src/gupax.rs b/src/gupax.rs index 0029b2b..64a2dd1 100644 --- a/src/gupax.rs +++ b/src/gupax.rs @@ -18,8 +18,7 @@ use crate::State; use crate::{constants::*, macros::*, update::*, ErrorState, Restart, Tab}; use egui::{ - Button, Checkbox, Label, ProgressBar, RichText, SelectableLabel, Slider, Spinner, TextEdit, - TextStyle, TextStyle::Monospace, Vec2, + Button, Checkbox, Label, ProgressBar, RichText, SelectableLabel, Slider, Spinner, TextEdit, Vec2, }; use log::*; use serde::{Deserialize, Serialize}; @@ -81,7 +80,7 @@ impl crate::disk::Gupax { restart: &Arc>, width: f32, height: f32, - frame: &mut eframe::Frame, + _frame: &mut eframe::Frame, _ctx: &egui::Context, ui: &mut egui::Ui, ) { @@ -512,7 +511,7 @@ impl crate::disk::Gupax { lock!(file_window).thread = true; thread::spawn(move || { match rfd::FileDialog::new() - .set_title(&format!("Select {} Binary for Gupax", name)) + .set_title(format!("Select {} Binary for Gupax", name)) .pick_file() { Some(path) => { diff --git a/src/helper.rs b/src/helper.rs index a5a449c..6ea7b77 100644 --- a/src/helper.rs +++ b/src/helper.rs @@ -1260,7 +1260,7 @@ impl Helper { // 1a. Create PTY debug!("XMRig | Creating PTY..."); let pty = portable_pty::native_pty_system(); - let mut pair = pty + let pair = pty .openpty(portable_pty::PtySize { rows: 100, cols: 1000, @@ -2393,7 +2393,7 @@ impl PubXmrigApi { // Formats raw private data into ready-to-print human readable version. fn update_from_priv(public: &Arc>, private: PrivXmrigApi) { let mut public = lock!(public); - let hashrate_raw = match private.hashrate.total.get(0) { + let hashrate_raw = match private.hashrate.total.first() { Some(Some(h)) => *h, _ => 0.0, }; diff --git a/src/main.rs b/src/main.rs index aaf882a..cb88fb1 100644 --- a/src/main.rs +++ b/src/main.rs @@ -29,14 +29,14 @@ compile_error!("gupax is only built for windows/macos/linux"); // egui/eframe use eframe::{egui, NativeOptions}; use egui::{ - Align, Button, CentralPanel, Color32, FontFamily::Proportional, FontId, Hyperlink, Key, Label, - Layout, Modifiers, RichText, SelectableLabel, Spinner, Stroke, TextEdit, TextStyle, + Align, Button, CentralPanel, Color32, FontId, Hyperlink, Key, Label, + Layout, Modifiers, RichText, SelectableLabel, Spinner, TextEdit, TextStyle, TextStyle::*, TopBottomPanel, Vec2, }; use egui_extras::RetainedImage; // Logging use env_logger::{ - fmt::style::{AnsiColor, Style}, + fmt::style::{Style}, Builder, WriteStyle, }; use log::*; @@ -237,7 +237,7 @@ impl App { let cpu = sysinfo.cpus()[0].brand(); let mut json: Vec = serde_json::from_slice(include_bytes!("cpu.json")).unwrap(); - json.sort_by(|a, b| cmp_f64(strsim::jaro(&b.cpu, &cpu), strsim::jaro(&a.cpu, &cpu))); + json.sort_by(|a, b| cmp_f64(strsim::jaro(&b.cpu, cpu), strsim::jaro(&a.cpu, cpu))); json }; info!("App Init | Assuming user's CPU is: {}", benchmarks[0].cpu); @@ -494,7 +494,7 @@ impl App { og.p2pool.selected_index, app.og_node_vec.len() ); - let (name, node) = match app.og_node_vec.get(0) { + let (name, node) = match app.og_node_vec.first() { Some(zero) => zero.clone(), None => Node::new_tuple(), }; @@ -517,7 +517,7 @@ impl App { og.xmrig.selected_index, app.og_pool_vec.len() ); - let (name, pool) = match app.og_pool_vec.get(0) { + let (name, pool) = match app.og_pool_vec.first() { Some(zero) => zero.clone(), None => Pool::new_tuple(), }; @@ -627,7 +627,7 @@ impl App { continue; } - let (ip, rpc, zmq) = RemoteNode::get_ip_rpc_zmq(&pinged_node.ip); + let (ip, rpc, zmq) = RemoteNode::get_ip_rpc_zmq(pinged_node.ip); let node = Node { ip: ip.into(), @@ -1868,17 +1868,11 @@ impl eframe::App for App { // They don't need to be compared anyway. debug!("App | Checking diff between [og] & [state]"); let og = lock!(self.og); - if og.status != self.state.status + self.diff = og.status != self.state.status || og.gupax != self.state.gupax || og.p2pool != self.state.p2pool || og.xmrig != self.state.xmrig - || self.og_node_vec != self.node_vec - || self.og_pool_vec != self.pool_vec - { - self.diff = true; - } else { - self.diff = false; - } + || self.og_node_vec != self.node_vec || self.og_pool_vec != self.pool_vec; drop(og); // Top: Tabs diff --git a/src/node.rs b/src/node.rs index 75d9732..ab7e1af 100644 --- a/src/node.rs +++ b/src/node.rs @@ -20,7 +20,7 @@ use egui::Color32; use hyper::{client::HttpConnector, Body, Client, Request}; use log::*; use rand::{thread_rng, Rng}; -use serde::{Deserialize, Serialize}; + use std::sync::{Arc, Mutex}; use std::time::{Duration, Instant}; @@ -414,7 +414,7 @@ impl Ping { let mut handles = Vec::with_capacity(REMOTE_NODE_LENGTH); let node_vec = arc_mut!(Vec::with_capacity(REMOTE_NODE_LENGTH)); - for (ip, _, rpc, zmq) in REMOTE_NODES { + for (ip, _, rpc, _zmq) in REMOTE_NODES { let client = client.clone(); let ping = Arc::clone(&ping); let node_vec = Arc::clone(&node_vec); diff --git a/src/p2pool.rs b/src/p2pool.rs index e855483..e4b8ef1 100644 --- a/src/p2pool.rs +++ b/src/p2pool.rs @@ -22,7 +22,7 @@ use egui::{ Slider, Spinner, TextEdit, TextStyle::*, }; use log::*; -use regex::Regex; + use std::sync::{Arc, Mutex}; impl crate::disk::P2pool { diff --git a/src/regex.rs b/src/regex.rs index 9ce9ae4..eca8ddb 100644 --- a/src/regex.rs +++ b/src/regex.rs @@ -21,9 +21,9 @@ use once_cell::sync::Lazy; use regex::Regex; //---------------------------------------------------------------------------------------------------- Lazy -pub static REGEXES: Lazy = Lazy::new(|| Regexes::new()); -pub static P2POOL_REGEX: Lazy = Lazy::new(|| P2poolRegex::new()); -pub static XMRIG_REGEX: Lazy = Lazy::new(|| XmrigRegex::new()); +pub static REGEXES: Lazy = Lazy::new(Regexes::new); +pub static P2POOL_REGEX: Lazy = Lazy::new(P2poolRegex::new); +pub static XMRIG_REGEX: Lazy = Lazy::new(XmrigRegex::new); //---------------------------------------------------------------------------------------------------- [Regexes] struct // General purpose Regexes, mostly used in the GUI. diff --git a/src/status.rs b/src/status.rs index ddfe206..fdcbd4f 100644 --- a/src/status.rs +++ b/src/status.rs @@ -20,8 +20,7 @@ use crate::{ ImgXmrig, PayoutView, PubP2poolApi, PubXmrigApi, Submenu, Sys, }; use egui::{ - Hyperlink, Label, ProgressBar, RichText, SelectableLabel, Slider, Spinner, TextEdit, TextStyle, - TextStyle::Monospace, TextStyle::Name, + Hyperlink, Label, ProgressBar, RichText, SelectableLabel, Slider, Spinner, TextEdit, TextStyle, TextStyle::Name, }; use log::*; use std::sync::{Arc, Mutex}; diff --git a/src/xmrig.rs b/src/xmrig.rs index 16caf50..21e41a5 100644 --- a/src/xmrig.rs +++ b/src/xmrig.rs @@ -21,7 +21,7 @@ use egui::{ Button, Checkbox, ComboBox, Label, RichText, SelectableLabel, Slider, TextEdit, TextStyle::*, }; use log::*; -use regex::Regex; + use std::sync::{Arc, Mutex}; impl crate::disk::Xmrig {