Skip to content

Commit

Permalink
clippy fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
ognevny committed Jul 30, 2024
1 parent 2a8b7e5 commit 538dab4
Show file tree
Hide file tree
Showing 83 changed files with 106 additions and 113 deletions.
2 changes: 1 addition & 1 deletion src/column.rs
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ macro_rules! column_default_sorted_pid {
fn sorted_pid(&self, order: &$crate::config::ConfigSortOrder) -> Vec<i32> {
let mut contents: Vec<(&i32, &$x)> = self.raw_contents.iter().collect();
contents.sort_by_key(|&(_x, y)| y);
if let $crate::config::ConfigSortOrder::Descending = order {
if matches!(*order, $crate::config::ConfigSortOrder::Descending) {
contents.reverse()
}
contents.iter().map(|(x, _y)| **x).collect()
Expand Down
2 changes: 1 addition & 1 deletion src/columns/ccgroup.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ impl Ccgroup {
pub fn new(header: Option<String>) -> Self {
let header = header.unwrap_or_else(|| String::from("Cgroup (compressed)"));
let unit = String::new();
Ccgroup {
Self {
fmt_contents: HashMap::new(),
raw_contents: HashMap::new(),
width: 0,
Expand Down
2 changes: 1 addition & 1 deletion src/columns/cgroup.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ impl Cgroup {
pub fn new(header: Option<String>) -> Self {
let header = header.unwrap_or_else(|| String::from("Cgroup"));
let unit = String::new();
Cgroup {
Self {
fmt_contents: HashMap::new(),
raw_contents: HashMap::new(),
width: 0,
Expand Down
2 changes: 1 addition & 1 deletion src/columns/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ impl Command {
pub fn new(header: Option<String>) -> Self {
let header = header.unwrap_or_else(|| String::from("Command"));
let unit = String::new();
Command {
Self {
fmt_contents: HashMap::new(),
raw_contents: HashMap::new(),
width: 0,
Expand Down
2 changes: 1 addition & 1 deletion src/columns/context_sw.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ impl ContextSw {
pub fn new(header: Option<String>) -> Self {
let header = header.unwrap_or_else(|| String::from("ContextSw"));
let unit = String::new();
ContextSw {
Self {
fmt_contents: HashMap::new(),
raw_contents: HashMap::new(),
width: 0,
Expand Down
2 changes: 1 addition & 1 deletion src/columns/cpu_time.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ impl CpuTime {
pub fn new(header: Option<String>) -> Self {
let header = header.unwrap_or_else(|| String::from("CPU Time"));
let unit = String::new();
CpuTime {
Self {
fmt_contents: HashMap::new(),
raw_contents: HashMap::new(),
width: 0,
Expand Down
2 changes: 1 addition & 1 deletion src/columns/docker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ impl Docker {
} else {
available = false;
}
Docker {
Self {
fmt_contents: HashMap::new(),
raw_contents: HashMap::new(),
width: 0,
Expand Down
2 changes: 1 addition & 1 deletion src/columns/eip.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ impl Eip {
pub fn new(header: Option<String>) -> Self {
let header = header.unwrap_or_else(|| String::from("EIP"));
let unit = String::new();
Eip {
Self {
fmt_contents: HashMap::new(),
raw_contents: HashMap::new(),
width: 0,
Expand Down
2 changes: 1 addition & 1 deletion src/columns/elapsed_time.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ impl ElapsedTime {
pub fn new(header: Option<String>) -> Self {
let header = header.unwrap_or_else(|| String::from("Elapsed"));
let unit = String::new();
ElapsedTime {
Self {
fmt_contents: HashMap::new(),
raw_contents: HashMap::new(),
width: 0,
Expand Down
2 changes: 1 addition & 1 deletion src/columns/empty.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ impl Empty {
pub fn new() -> Self {
let header = String::new();
let unit = String::new();
Empty {
Self {
fmt_contents: HashMap::new(),
raw_contents: HashMap::new(),
width: 0,
Expand Down
2 changes: 1 addition & 1 deletion src/columns/env.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ impl Env {
pub fn new(header: Option<String>) -> Self {
let header = header.unwrap_or_else(|| String::from("Env"));
let unit = String::new();
Env {
Self {
fmt_contents: HashMap::new(),
raw_contents: HashMap::new(),
width: 0,
Expand Down
2 changes: 1 addition & 1 deletion src/columns/esp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ impl Esp {
pub fn new(header: Option<String>) -> Self {
let header = header.unwrap_or_else(|| String::from("ESP"));
let unit = String::new();
Esp {
Self {
fmt_contents: HashMap::new(),
raw_contents: HashMap::new(),
width: 0,
Expand Down
2 changes: 1 addition & 1 deletion src/columns/file_name.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ impl FileName {
pub fn new(header: Option<String>) -> Self {
let header = header.unwrap_or_else(|| String::from("FileName"));
let unit = String::new();
FileName {
Self {
fmt_contents: HashMap::new(),
raw_contents: HashMap::new(),
width: 0,
Expand Down
4 changes: 2 additions & 2 deletions src/columns/gid.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ impl Gid {
pub fn new(header: Option<String>, abbr_sid: bool) -> Self {
let header = header.unwrap_or_else(|| String::from("GID"));
let unit = String::new();
Gid {
Self {
fmt_contents: HashMap::new(),
raw_contents: HashMap::new(),
width: 0,
Expand Down Expand Up @@ -65,7 +65,7 @@ impl Column for Gid {
impl Column for Gid {
fn add(&mut self, proc: &ProcessInfo) {
let mut sid = &proc.groups[0].sid;
let mut kind = std::u64::MAX;
let mut kind = u64::MAX;
for g in &proc.groups {
if g.sid.len() > 3 && g.sid[1] == 5 && g.sid[2] == 32 && kind > g.sid[3] {
sid = &g.sid;
Expand Down
2 changes: 1 addition & 1 deletion src/columns/gid_fs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ impl GidFs {
pub fn new(header: Option<String>) -> Self {
let header = header.unwrap_or_else(|| String::from("FGID"));
let unit = String::new();
GidFs {
Self {
fmt_contents: HashMap::new(),
raw_contents: HashMap::new(),
width: 0,
Expand Down
2 changes: 1 addition & 1 deletion src/columns/gid_real.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ impl GidReal {
pub fn new(header: Option<String>) -> Self {
let header = header.unwrap_or_else(|| String::from("RGID"));
let unit = String::new();
GidReal {
Self {
fmt_contents: HashMap::new(),
raw_contents: HashMap::new(),
width: 0,
Expand Down
2 changes: 1 addition & 1 deletion src/columns/gid_saved.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ impl GidSaved {
pub fn new(header: Option<String>) -> Self {
let header = header.unwrap_or_else(|| String::from("SGID"));
let unit = String::new();
GidSaved {
Self {
fmt_contents: HashMap::new(),
raw_contents: HashMap::new(),
width: 0,
Expand Down
4 changes: 2 additions & 2 deletions src/columns/group.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ impl Group {
pub fn new(header: Option<String>, abbr_sid: bool) -> Self {
let header = header.unwrap_or_else(|| String::from("Group"));
let unit = String::new();
Group {
Self {
fmt_contents: HashMap::new(),
raw_contents: HashMap::new(),
width: 0,
Expand Down Expand Up @@ -79,7 +79,7 @@ impl Column for Group {
impl Column for Group {
fn add(&mut self, proc: &ProcessInfo) {
let mut sid_name = &proc.groups[0];
let mut kind = std::u64::MAX;
let mut kind = u64::MAX;
for g in &proc.groups {
if g.sid.len() > 3 && g.sid[1] == 5 && g.sid[2] == 32 && kind > g.sid[3] {
sid_name = g;
Expand Down
2 changes: 1 addition & 1 deletion src/columns/group_fs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ impl GroupFs {
pub fn new(header: Option<String>) -> Self {
let header = header.unwrap_or_else(|| String::from("File System Group"));
let unit = String::new();
GroupFs {
Self {
fmt_contents: HashMap::new(),
raw_contents: HashMap::new(),
width: 0,
Expand Down
2 changes: 1 addition & 1 deletion src/columns/group_real.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ impl GroupReal {
pub fn new(header: Option<String>) -> Self {
let header = header.unwrap_or_else(|| String::from("Real Group"));
let unit = String::new();
GroupReal {
Self {
fmt_contents: HashMap::new(),
raw_contents: HashMap::new(),
width: 0,
Expand Down
2 changes: 1 addition & 1 deletion src/columns/group_saved.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ impl GroupSaved {
pub fn new(header: Option<String>) -> Self {
let header = header.unwrap_or_else(|| String::from("Saved Group"));
let unit = String::new();
GroupSaved {
Self {
fmt_contents: HashMap::new(),
raw_contents: HashMap::new(),
width: 0,
Expand Down
6 changes: 3 additions & 3 deletions src/columns/maj_flt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ impl MajFlt {
pub fn new(header: Option<String>) -> Self {
let header = header.unwrap_or_else(|| String::from("MajorFaults"));
let unit = String::new();
MajFlt {
Self {
fmt_contents: HashMap::new(),
raw_contents: HashMap::new(),
width: 0,
Expand All @@ -42,7 +42,7 @@ impl Column for MajFlt {
impl Column for MajFlt {
fn add(&mut self, proc: &ProcessInfo) {
let raw_content = proc.curr_task.ptinfo.pti_pageins as u64;
let fmt_content = format!("{}", raw_content);
let fmt_content = format!("{raw_content}");

self.fmt_contents.insert(proc.pid, fmt_content);
self.raw_contents.insert(proc.pid, raw_content);
Expand All @@ -55,7 +55,7 @@ impl Column for MajFlt {
impl Column for MajFlt {
fn add(&mut self, proc: &ProcessInfo) {
let raw_content = proc.memory_info.page_fault_count;
let fmt_content = format!("{}", raw_content);
let fmt_content = format!("{raw_content}");

self.fmt_contents.insert(proc.pid, fmt_content);
self.raw_contents.insert(proc.pid, raw_content);
Expand Down
2 changes: 1 addition & 1 deletion src/columns/min_flt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ impl MinFlt {
pub fn new(header: Option<String>) -> Self {
let header = header.unwrap_or_else(|| String::from("MinorFaults"));
let unit = String::new();
MinFlt {
Self {
fmt_contents: HashMap::new(),
raw_contents: HashMap::new(),
width: 0,
Expand Down
2 changes: 1 addition & 1 deletion src/columns/multi_slot.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ impl MultiSlot {
pub fn new() -> Self {
let header = String::new();
let unit = String::new();
MultiSlot {
Self {
fmt_contents: HashMap::new(),
raw_contents: HashMap::new(),
width: 0,
Expand Down
2 changes: 1 addition & 1 deletion src/columns/nice.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ impl Nice {
pub fn new(header: Option<String>) -> Self {
let header = header.unwrap_or_else(|| String::from("Nice"));
let unit = String::new();
Nice {
Self {
fmt_contents: HashMap::new(),
raw_contents: HashMap::new(),
width: 0,
Expand Down
2 changes: 1 addition & 1 deletion src/columns/pgid.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ impl Pgid {
pub fn new(header: Option<String>) -> Self {
let header = header.unwrap_or_else(|| String::from("PGID"));
let unit = String::new();
Pgid {
Self {
fmt_contents: HashMap::new(),
raw_contents: HashMap::new(),
width: 0,
Expand Down
4 changes: 2 additions & 2 deletions src/columns/pid.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ impl Pid {
pub fn new(header: Option<String>) -> Self {
let header = header.unwrap_or_else(|| String::from("PID"));
let unit = String::new();
Pid {
Self {
fmt_contents: HashMap::new(),
raw_contents: HashMap::new(),
width: 0,
Expand Down Expand Up @@ -45,7 +45,7 @@ impl Column for Pid {
impl Column for Pid {
fn add(&mut self, proc: &ProcessInfo) {
let raw_content = proc.pid;
let fmt_content = format!("{}", raw_content);
let fmt_content = format!("{raw_content}");

self.fmt_contents.insert(proc.pid, fmt_content);
self.raw_contents.insert(proc.pid, raw_content);
Expand Down
2 changes: 1 addition & 1 deletion src/columns/policy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ impl Policy {
pub fn new(header: Option<String>) -> Self {
let header = header.unwrap_or_else(|| String::from("Policy"));
let unit = String::new();
Policy {
Self {
fmt_contents: HashMap::new(),
raw_contents: HashMap::new(),
width: 0,
Expand Down
2 changes: 1 addition & 1 deletion src/columns/ppid.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ impl Ppid {
pub fn new(header: Option<String>) -> Self {
let header = header.unwrap_or_else(|| String::from("Parent PID"));
let unit = String::new();
Ppid {
Self {
fmt_contents: HashMap::new(),
raw_contents: HashMap::new(),
width: 0,
Expand Down
2 changes: 1 addition & 1 deletion src/columns/priority.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ impl Priority {
pub fn new(header: Option<String>) -> Self {
let header = header.unwrap_or_else(|| String::from("Priority"));
let unit = String::new();
Priority {
Self {
fmt_contents: HashMap::new(),
raw_contents: HashMap::new(),
width: 0,
Expand Down
2 changes: 1 addition & 1 deletion src/columns/processor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ impl Processor {
pub fn new(header: Option<String>) -> Self {
let header = header.unwrap_or_else(|| String::from("Processor"));
let unit = String::new();
Processor {
Self {
fmt_contents: HashMap::new(),
raw_contents: HashMap::new(),
width: 0,
Expand Down
2 changes: 1 addition & 1 deletion src/columns/read_bytes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ impl ReadBytes {
pub fn new(header: Option<String>) -> Self {
let header = header.unwrap_or_else(|| String::from("Read"));
let unit = String::from("[B/s]");
ReadBytes {
Self {
fmt_contents: HashMap::new(),
raw_contents: HashMap::new(),
width: 0,
Expand Down
2 changes: 1 addition & 1 deletion src/columns/rt_priority.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ impl RtPriority {
pub fn new(header: Option<String>) -> Self {
let header = header.unwrap_or_else(|| String::from("RT Priority"));
let unit = String::new();
RtPriority {
Self {
fmt_contents: HashMap::new(),
raw_contents: HashMap::new(),
width: 0,
Expand Down
2 changes: 1 addition & 1 deletion src/columns/sec_context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ impl SecContext {
pub fn new(header: Option<String>) -> Self {
let header = header.unwrap_or_else(|| String::from("Context"));
let unit = String::new();
SecContext {
Self {
fmt_contents: HashMap::new(),
raw_contents: HashMap::new(),
width: 0,
Expand Down
2 changes: 1 addition & 1 deletion src/columns/separator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ impl Separator {
pub fn new(separator: &str) -> Self {
let header = String::from(separator);
let unit = String::from(separator);
Separator {
Self {
fmt_contents: HashMap::new(),
raw_contents: HashMap::new(),
width: 0,
Expand Down
2 changes: 1 addition & 1 deletion src/columns/session.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ impl Session {
pub fn new(header: Option<String>) -> Self {
let header = header.unwrap_or_else(|| String::from("Session"));
let unit = String::new();
Session {
Self {
fmt_contents: HashMap::new(),
raw_contents: HashMap::new(),
width: 0,
Expand Down
2 changes: 1 addition & 1 deletion src/columns/shd_pnd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ impl ShdPnd {
pub fn new(header: Option<String>) -> Self {
let header = header.unwrap_or_else(|| String::from("ShdPnd"));
let unit = String::new();
ShdPnd {
Self {
fmt_contents: HashMap::new(),
raw_contents: HashMap::new(),
width: 0,
Expand Down
2 changes: 1 addition & 1 deletion src/columns/sig_blk.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ impl SigBlk {
pub fn new(header: Option<String>) -> Self {
let header = header.unwrap_or_else(|| String::from("SigBlk"));
let unit = String::new();
SigBlk {
Self {
fmt_contents: HashMap::new(),
raw_contents: HashMap::new(),
width: 0,
Expand Down
2 changes: 1 addition & 1 deletion src/columns/sig_cgt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ impl SigCgt {
pub fn new(header: Option<String>) -> Self {
let header = header.unwrap_or_else(|| String::from("SigCgt"));
let unit = String::new();
SigCgt {
Self {
fmt_contents: HashMap::new(),
raw_contents: HashMap::new(),
width: 0,
Expand Down
Loading

0 comments on commit 538dab4

Please sign in to comment.