Ran Clippy

This commit is contained in:
2024-05-27 19:20:19 +01:00
parent 0396f19fa6
commit 07fe0ca003

View File

@@ -67,8 +67,8 @@ struct SysInfo {
} }
fn get_system_info( fn get_system_info(
network_if_names: &Vec<String>, network_if_names: &[String],
mount_names: &Vec<String>, mount_names: &[String],
temperature_sensors: &Vec<Vec<String>>, temperature_sensors: &Vec<Vec<String>>,
) -> SysInfo { ) -> SysInfo {
let mut sys = System::new_all(); let mut sys = System::new_all();
@@ -84,7 +84,7 @@ fn get_system_info(
let mut disks_context = Vec::new(); let mut disks_context = Vec::new();
for disk in disks.list() { for disk in disks.list() {
let mount_point = disk.mount_point().display().to_string(); let mount_point = disk.mount_point().display().to_string();
if mount_names.len() != 0 && !mount_names.contains(&mount_point) { if !mount_names.is_empty() && !mount_names.contains(&mount_point) {
continue; continue;
} }
let ts = disk.total_space(); let ts = disk.total_space();
@@ -96,7 +96,7 @@ fn get_system_info(
available_space: Byte::from(ass).to_string(), available_space: Byte::from(ass).to_string(),
available_space_bytes: ass, available_space_bytes: ass,
consumed_space_bytes: ts - ass, consumed_space_bytes: ts - ass,
mount_point: mount_point, mount_point,
}); });
} }
@@ -113,7 +113,7 @@ fn get_system_info(
}); });
} }
} }
if temperature_sensors.len() == 0 { if temperature_sensors.is_empty() {
components_context.push(ComponentInfo { components_context.push(ComponentInfo {
name: component_name, name: component_name,
temperature: component.temperature() as u8, temperature: component.temperature() as u8,
@@ -124,7 +124,7 @@ fn get_system_info(
let mut network_ifs = Vec::new(); let mut network_ifs = Vec::new();
let mut network_ifs_errored = Vec::new(); let mut network_ifs_errored = Vec::new();
for network_if_name in network_if_names { for network_if_name in network_if_names {
match Vnstat::get(&network_if_name) { match Vnstat::get(network_if_name) {
Ok(vns) => { Ok(vns) => {
network_ifs.push(NetworkInfo { network_ifs.push(NetworkInfo {
name: network_if_name.to_string(), name: network_if_name.to_string(),
@@ -150,8 +150,8 @@ fn get_system_info(
total_swap_pretty: Byte::from(sys.total_swap()).to_string(), total_swap_pretty: Byte::from(sys.total_swap()).to_string(),
used_swap_pretty: Byte::from(sys.used_swap()).to_string(), used_swap_pretty: Byte::from(sys.used_swap()).to_string(),
}, },
network_ifs: network_ifs, network_ifs,
network_ifs_errored: network_ifs_errored, network_ifs_errored,
hostname: System::host_name(), hostname: System::host_name(),
operating_system: System::long_os_version(), operating_system: System::long_os_version(),
uptime: UptimeFull::from(System::uptime()).to_string(), uptime: UptimeFull::from(System::uptime()).to_string(),
@@ -227,10 +227,10 @@ fn get_latest_twenty_blocks(json_rpc_url: &str, current_height: u64) -> Vec<Bloc
}) })
.unwrap(); .unwrap();
let mut latest_twenty_blocks = blocks.result.headers; let mut latest_twenty_blocks = blocks.result.headers;
for i in 0..latest_twenty_blocks.len() { for block in &mut latest_twenty_blocks {
let clock_time = secs_to_clock(unix_clock(latest_twenty_blocks[i].timestamp)); let clock_time = secs_to_clock(unix_clock(block.timestamp));
let date = Date::from_unix(latest_twenty_blocks[i].timestamp).unwrap(); let date = Date::from_unix(block.timestamp).unwrap();
latest_twenty_blocks[i].timestamp_pretty = format!( block.timestamp_pretty = format!(
"{} {:02}-{:02}-{:02}", "{} {:02}-{:02}-{:02}",
date, clock_time.0, clock_time.1, clock_time.2 date, clock_time.0, clock_time.1, clock_time.2
); );
@@ -274,7 +274,7 @@ fn index(config: &State<Config>) -> Template {
node_info: node_info, node_info: node_info,
latest_twenty_blocks: latest_twenty_blocks, latest_twenty_blocks: latest_twenty_blocks,
}; };
Template::render("index", &context) Template::render("index", context)
} }
#[launch] #[launch]