Skip to content

Commit

Permalink
feat: cargo clippy
Browse files Browse the repository at this point in the history
  • Loading branch information
Cyrix126 committed Feb 27, 2024
1 parent 5ef88ad commit d811f60
Show file tree
Hide file tree
Showing 10 changed files with 26 additions and 34 deletions.
2 changes: 1 addition & 1 deletion src/constants.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
6 changes: 3 additions & 3 deletions src/disk.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(())
}

Expand Down
7 changes: 3 additions & 4 deletions src/gupax.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand Down Expand Up @@ -81,7 +80,7 @@ impl crate::disk::Gupax {
restart: &Arc<Mutex<Restart>>,
width: f32,
height: f32,
frame: &mut eframe::Frame,
_frame: &mut eframe::Frame,
_ctx: &egui::Context,
ui: &mut egui::Ui,
) {
Expand Down Expand Up @@ -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) => {
Expand Down
4 changes: 2 additions & 2 deletions src/helper.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -2393,7 +2393,7 @@ impl PubXmrigApi {
// Formats raw private data into ready-to-print human readable version.
fn update_from_priv(public: &Arc<Mutex<Self>>, 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,
};
Expand Down
24 changes: 9 additions & 15 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::*;
Expand Down Expand Up @@ -237,7 +237,7 @@ impl App {
let cpu = sysinfo.cpus()[0].brand();
let mut json: Vec<Benchmark> =
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);
Expand Down Expand Up @@ -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(),
};
Expand All @@ -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(),
};
Expand Down Expand Up @@ -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(),
Expand Down Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions src/node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};

Expand Down Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion src/p2pool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ use egui::{
Slider, Spinner, TextEdit, TextStyle::*,
};
use log::*;
use regex::Regex;

use std::sync::{Arc, Mutex};

impl crate::disk::P2pool {
Expand Down
6 changes: 3 additions & 3 deletions src/regex.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ use once_cell::sync::Lazy;
use regex::Regex;

//---------------------------------------------------------------------------------------------------- Lazy
pub static REGEXES: Lazy<Regexes> = Lazy::new(|| Regexes::new());
pub static P2POOL_REGEX: Lazy<P2poolRegex> = Lazy::new(|| P2poolRegex::new());
pub static XMRIG_REGEX: Lazy<XmrigRegex> = Lazy::new(|| XmrigRegex::new());
pub static REGEXES: Lazy<Regexes> = Lazy::new(Regexes::new);
pub static P2POOL_REGEX: Lazy<P2poolRegex> = Lazy::new(P2poolRegex::new);
pub static XMRIG_REGEX: Lazy<XmrigRegex> = Lazy::new(XmrigRegex::new);

//---------------------------------------------------------------------------------------------------- [Regexes] struct
// General purpose Regexes, mostly used in the GUI.
Expand Down
3 changes: 1 addition & 2 deletions src/status.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand Down
2 changes: 1 addition & 1 deletion src/xmrig.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit d811f60

Please sign in to comment.