chore: Minor cleanup - remove un-needed ident qualifiers (#1307)
Keep code a bit tidier and consistent (i.e. if an identifier already has a `use` entry above, why in some cases still prove a full path to it?)
This commit is contained in:
parent
4174012b8f
commit
1e16456d5f
2
build.rs
2
build.rs
|
@ -57,7 +57,7 @@ fn btm_generate() -> io::Result<()> {
|
||||||
let man = clap_mangen::Man::new(app);
|
let man = clap_mangen::Man::new(app);
|
||||||
let mut buffer: Vec<u8> = Default::default();
|
let mut buffer: Vec<u8> = Default::default();
|
||||||
man.render(&mut buffer)?;
|
man.render(&mut buffer)?;
|
||||||
std::fs::write(manpage_out_dir.join("btm.1"), buffer)?;
|
fs::write(manpage_out_dir.join("btm.1"), buffer)?;
|
||||||
}
|
}
|
||||||
_ => {}
|
_ => {}
|
||||||
}
|
}
|
||||||
|
|
|
@ -124,7 +124,7 @@ pub struct DataCollector {
|
||||||
battery_list: Option<Vec<Battery>>,
|
battery_list: Option<Vec<Battery>>,
|
||||||
|
|
||||||
#[cfg(target_family = "unix")]
|
#[cfg(target_family = "unix")]
|
||||||
user_table: self::processes::UserTable,
|
user_table: processes::UserTable,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl DataCollector {
|
impl DataCollector {
|
||||||
|
|
|
@ -8,9 +8,7 @@ use sysinfo::{CpuExt, LoadAvg, System, SystemExt};
|
||||||
use super::{CpuData, CpuDataType, CpuHarvest};
|
use super::{CpuData, CpuDataType, CpuHarvest};
|
||||||
use crate::app::data_harvester::cpu::LoadAvgHarvest;
|
use crate::app::data_harvester::cpu::LoadAvgHarvest;
|
||||||
|
|
||||||
pub fn get_cpu_data_list(
|
pub fn get_cpu_data_list(sys: &System, show_average_cpu: bool) -> crate::error::Result<CpuHarvest> {
|
||||||
sys: &sysinfo::System, show_average_cpu: bool,
|
|
||||||
) -> crate::error::Result<CpuHarvest> {
|
|
||||||
let mut cpu_deque: VecDeque<_> = sys
|
let mut cpu_deque: VecDeque<_> = sys
|
||||||
.cpus()
|
.cpus()
|
||||||
.iter()
|
.iter()
|
||||||
|
|
|
@ -51,7 +51,7 @@ impl Partition {
|
||||||
.into_string()
|
.into_string()
|
||||||
.unwrap_or_else(|_| "Name Unavailable".to_string())
|
.unwrap_or_else(|_| "Name Unavailable".to_string())
|
||||||
} else {
|
} else {
|
||||||
let mut combined_path = std::path::PathBuf::new();
|
let mut combined_path = PathBuf::new();
|
||||||
combined_path.push(device);
|
combined_path.push(device);
|
||||||
combined_path.pop(); // Pop the current file...
|
combined_path.pop(); // Pop the current file...
|
||||||
combined_path.push(path);
|
combined_path.push(path);
|
||||||
|
@ -110,7 +110,7 @@ impl FromStr for Partition {
|
||||||
let mut parts = line.splitn(5, ' ');
|
let mut parts = line.splitn(5, ' ');
|
||||||
|
|
||||||
let device = match parts.next() {
|
let device = match parts.next() {
|
||||||
Some(device) if device == "none" => None,
|
Some("none") => None,
|
||||||
Some(device) => Some(device.to_string()),
|
Some(device) => Some(device.to_string()),
|
||||||
None => {
|
None => {
|
||||||
bail!("missing device");
|
bail!("missing device");
|
||||||
|
|
|
@ -717,7 +717,7 @@ impl Prefix {
|
||||||
let rhs: f64 = rhs.into();
|
let rhs: f64 = rhs.into();
|
||||||
|
|
||||||
match condition {
|
match condition {
|
||||||
QueryComparison::Equal => (lhs - rhs).abs() < std::f64::EPSILON,
|
QueryComparison::Equal => (lhs - rhs).abs() < f64::EPSILON,
|
||||||
QueryComparison::Less => lhs < rhs,
|
QueryComparison::Less => lhs < rhs,
|
||||||
QueryComparison::Greater => lhs > rhs,
|
QueryComparison::Greater => lhs > rhs,
|
||||||
QueryComparison::LessOrEqual => lhs <= rhs,
|
QueryComparison::LessOrEqual => lhs <= rhs,
|
||||||
|
|
|
@ -84,7 +84,7 @@ Supported widget names:
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
pub fn get_matches() -> clap::ArgMatches {
|
pub fn get_matches() -> ArgMatches {
|
||||||
build_app().get_matches()
|
build_app().get_matches()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -38,9 +38,7 @@ fn main() -> Result<()> {
|
||||||
|
|
||||||
#[cfg(feature = "logging")]
|
#[cfg(feature = "logging")]
|
||||||
{
|
{
|
||||||
if let Err(err) =
|
if let Err(err) = init_logger(log::LevelFilter::Debug, std::ffi::OsStr::new("debug.log")) {
|
||||||
utils::logging::init_logger(log::LevelFilter::Debug, std::ffi::OsStr::new("debug.log"))
|
|
||||||
{
|
|
||||||
println!("Issue initializing logger: {err}");
|
println!("Issue initializing logger: {err}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,7 +12,6 @@ use tui::{
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
app::{
|
app::{
|
||||||
self,
|
|
||||||
layout_manager::{BottomColRow, BottomLayout, BottomWidgetType},
|
layout_manager::{BottomColRow, BottomLayout, BottomWidgetType},
|
||||||
App,
|
App,
|
||||||
},
|
},
|
||||||
|
@ -227,7 +226,7 @@ impl Painter {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn draw_data<B: Backend>(
|
pub fn draw_data<B: Backend>(
|
||||||
&mut self, terminal: &mut Terminal<B>, app_state: &mut app::App,
|
&mut self, terminal: &mut Terminal<B>, app_state: &mut App,
|
||||||
) -> error::Result<()> {
|
) -> error::Result<()> {
|
||||||
use BottomWidgetType::*;
|
use BottomWidgetType::*;
|
||||||
|
|
||||||
|
|
|
@ -91,7 +91,7 @@ impl Default for CanvasStyling {
|
||||||
high_battery_colour: Style::default().fg(Color::Green),
|
high_battery_colour: Style::default().fg(Color::Green),
|
||||||
medium_battery_colour: Style::default().fg(Color::Yellow),
|
medium_battery_colour: Style::default().fg(Color::Yellow),
|
||||||
low_battery_colour: Style::default().fg(Color::Red),
|
low_battery_colour: Style::default().fg(Color::Red),
|
||||||
invalid_query_style: Style::default().fg(tui::style::Color::Red),
|
invalid_query_style: Style::default().fg(Color::Red),
|
||||||
disabled_text_style: Style::default().fg(Color::DarkGray),
|
disabled_text_style: Style::default().fg(Color::DarkGray),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -546,9 +546,7 @@ pub fn convert_battery_harvest(current_data: &DataCollection) -> Vec<ConvertedBa
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "zfs")]
|
#[cfg(feature = "zfs")]
|
||||||
pub fn convert_arc_labels(
|
pub fn convert_arc_labels(current_data: &DataCollection) -> Option<(String, String)> {
|
||||||
current_data: &crate::app::data_farmer::DataCollection,
|
|
||||||
) -> Option<(String, String)> {
|
|
||||||
if current_data.arc_harvest.total_bytes > 0 {
|
if current_data.arc_harvest.total_bytes > 0 {
|
||||||
Some((
|
Some((
|
||||||
format!(
|
format!(
|
||||||
|
@ -572,9 +570,7 @@ pub fn convert_arc_labels(
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "zfs")]
|
#[cfg(feature = "zfs")]
|
||||||
pub fn convert_arc_data_points(
|
pub fn convert_arc_data_points(current_data: &DataCollection) -> Vec<Point> {
|
||||||
current_data: &crate::app::data_farmer::DataCollection,
|
|
||||||
) -> Vec<Point> {
|
|
||||||
let mut result: Vec<Point> = Vec::new();
|
let mut result: Vec<Point> = Vec::new();
|
||||||
let current_time = current_data.current_instant;
|
let current_time = current_data.current_instant;
|
||||||
|
|
||||||
|
@ -602,9 +598,7 @@ pub struct ConvertedGpuData {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "gpu")]
|
#[cfg(feature = "gpu")]
|
||||||
pub fn convert_gpu_data(
|
pub fn convert_gpu_data(current_data: &DataCollection) -> Option<Vec<ConvertedGpuData>> {
|
||||||
current_data: &crate::app::data_farmer::DataCollection,
|
|
||||||
) -> Option<Vec<ConvertedGpuData>> {
|
|
||||||
let current_time = current_data.current_instant;
|
let current_time = current_data.current_instant;
|
||||||
|
|
||||||
// convert points
|
// convert points
|
||||||
|
|
|
@ -538,7 +538,7 @@ pub fn get_widget_layout(
|
||||||
|
|
||||||
ret_bottom_layout
|
ret_bottom_layout
|
||||||
} else {
|
} else {
|
||||||
return Err(error::BottomError::ConfigError(
|
return Err(BottomError::ConfigError(
|
||||||
"please have at least one widget under the '[[row]]' section.".to_string(),
|
"please have at least one widget under the '[[row]]' section.".to_string(),
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
|
@ -48,8 +48,8 @@ impl From<std::num::ParseIntError> for BottomError {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<std::string::String> for BottomError {
|
impl From<String> for BottomError {
|
||||||
fn from(err: std::string::String) -> Self {
|
fn from(err: String) -> Self {
|
||||||
BottomError::GenericError(err)
|
BottomError::GenericError(err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -178,7 +178,7 @@ fn truncate_str<U: Into<usize>>(content: &str, width: U) -> String {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub const fn sort_partial_fn<T: std::cmp::PartialOrd>(is_descending: bool) -> fn(T, T) -> Ordering {
|
pub const fn sort_partial_fn<T: PartialOrd>(is_descending: bool) -> fn(T, T) -> Ordering {
|
||||||
if is_descending {
|
if is_descending {
|
||||||
partial_ordering_desc
|
partial_ordering_desc
|
||||||
} else {
|
} else {
|
||||||
|
@ -188,7 +188,7 @@ pub const fn sort_partial_fn<T: std::cmp::PartialOrd>(is_descending: bool) -> fn
|
||||||
|
|
||||||
/// Returns an [`Ordering`] between two [`PartialOrd`]s.
|
/// Returns an [`Ordering`] between two [`PartialOrd`]s.
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn partial_ordering<T: std::cmp::PartialOrd>(a: T, b: T) -> Ordering {
|
pub fn partial_ordering<T: PartialOrd>(a: T, b: T) -> Ordering {
|
||||||
a.partial_cmp(&b).unwrap_or(Ordering::Equal)
|
a.partial_cmp(&b).unwrap_or(Ordering::Equal)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -197,7 +197,7 @@ pub fn partial_ordering<T: std::cmp::PartialOrd>(a: T, b: T) -> Ordering {
|
||||||
/// This is simply a wrapper function around [`partial_ordering`] that reverses
|
/// This is simply a wrapper function around [`partial_ordering`] that reverses
|
||||||
/// the result.
|
/// the result.
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn partial_ordering_desc<T: std::cmp::PartialOrd>(a: T, b: T) -> Ordering {
|
pub fn partial_ordering_desc<T: PartialOrd>(a: T, b: T) -> Ordering {
|
||||||
partial_ordering(a, b).reverse()
|
partial_ordering(a, b).reverse()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -140,7 +140,7 @@ impl<'de> Deserialize<'de> for ProcWidgetColumn {
|
||||||
"state" => Ok(ProcWidgetColumn::State),
|
"state" => Ok(ProcWidgetColumn::State),
|
||||||
"user" => Ok(ProcWidgetColumn::User),
|
"user" => Ok(ProcWidgetColumn::User),
|
||||||
"time" => Ok(ProcWidgetColumn::Time),
|
"time" => Ok(ProcWidgetColumn::Time),
|
||||||
_ => Err(D::Error::custom("doesn't match any column type")),
|
_ => Err(Error::custom("doesn't match any column type")),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -47,7 +47,7 @@ impl<'de> Deserialize<'de> for ProcColumn {
|
||||||
"state" => Ok(ProcColumn::State),
|
"state" => Ok(ProcColumn::State),
|
||||||
"user" => Ok(ProcColumn::User),
|
"user" => Ok(ProcColumn::User),
|
||||||
"time" => Ok(ProcColumn::Time),
|
"time" => Ok(ProcColumn::Time),
|
||||||
_ => Err(D::Error::custom("doesn't match any column type")),
|
_ => Err(Error::custom("doesn't match any column type")),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,7 +10,7 @@ use crate::{
|
||||||
pub struct SortTableColumn;
|
pub struct SortTableColumn;
|
||||||
|
|
||||||
impl ColumnHeader for SortTableColumn {
|
impl ColumnHeader for SortTableColumn {
|
||||||
fn text(&self) -> std::borrow::Cow<'static, str> {
|
fn text(&self) -> Cow<'static, str> {
|
||||||
"Sort By".into()
|
"Sort By".into()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,7 +24,7 @@ fn cross_runner() -> Option<String> {
|
||||||
const TARGET_RUNNER: &str = "CARGO_TARGET_RUNNER";
|
const TARGET_RUNNER: &str = "CARGO_TARGET_RUNNER";
|
||||||
const CROSS_RUNNER: &str = "CROSS_RUNNER";
|
const CROSS_RUNNER: &str = "CROSS_RUNNER";
|
||||||
|
|
||||||
let env_mapping = std::env::vars_os()
|
let env_mapping = env::vars_os()
|
||||||
.filter_map(|(k, v)| {
|
.filter_map(|(k, v)| {
|
||||||
let (k, v) = (k.to_string_lossy(), v.to_string_lossy());
|
let (k, v) = (k.to_string_lossy(), v.to_string_lossy());
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue