Skip to content

Commit 04007b0

Browse files
authored
Merge pull request #877 from dalance/fix_ci
Update MSRV to 1.88
2 parents 9eb423b + 0770243 commit 04007b0

File tree

19 files changed

+108
-112
lines changed

19 files changed

+108
-112
lines changed

.github/workflows/regression.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ jobs:
5555
- uses: actions/checkout@v3
5656
- uses: dtolnay/rust-toolchain@v1
5757
with:
58-
toolchain: 1.76.0
58+
toolchain: 1.88.0
5959
targets: x86_64-unknown-linux-gnu
6060
- name: Run build
6161
run: cargo build

Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@ categories = ["command-line-utilities"]
88
license = "MIT"
99
readme = "README.md"
1010
description = "A modern replacement for ps"
11-
edition = "2021"
11+
edition = "2024"
1212
exclude = ["img/*", "config/*"]
13-
rust-version = "1.76"
13+
rust-version = "1.88"
1414

1515
[package.metadata.release]
1616
pre-release-commit-message = "Prepare to v{{version}}"

src/columns/context_sw.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,11 @@ impl ContextSw {
3030
impl Column for ContextSw {
3131
fn add(&mut self, proc: &ProcessInfo) {
3232
let (fmt_content, raw_content) = if let Some(ref status) = proc.curr_status {
33-
if status.voluntary_ctxt_switches.is_some()
34-
&& status.nonvoluntary_ctxt_switches.is_some()
33+
if let Some(voluntary_ctxt_switches) = status.voluntary_ctxt_switches
34+
&& let Some(nonvoluntary_ctxt_switches) = status.nonvoluntary_ctxt_switches
3535
{
36-
let sw = status.voluntary_ctxt_switches.unwrap()
37-
+ status.nonvoluntary_ctxt_switches.unwrap();
36+
let sw = voluntary_ctxt_switches
37+
+ nonvoluntary_ctxt_switches;
3838
(bytify(sw), sw)
3939
} else {
4040
(String::new(), 0)

src/columns/env.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use crate::process::ProcessInfo;
2-
use crate::{column_default, Column};
2+
use crate::{Column, column_default};
33
use std::cmp;
44
use std::collections::HashMap;
55
use std::path::PathBuf;
@@ -33,15 +33,15 @@ impl Env {
3333
impl Column for Env {
3434
fn add(&mut self, proc: &ProcessInfo) {
3535
let mut fmt_content = String::new();
36-
if let Ok(proc) = crate::util::process_new(proc.pid, &self.procfs) {
37-
if let Ok(envs) = proc.environ() {
38-
for (k, v) in envs {
39-
fmt_content.push_str(&format!(
40-
"{}=\"{}\" ",
41-
k.to_string_lossy(),
42-
v.to_string_lossy().replace('\"', "\\\"")
43-
));
44-
}
36+
if let Ok(proc) = crate::util::process_new(proc.pid, &self.procfs)
37+
&& let Ok(envs) = proc.environ()
38+
{
39+
for (k, v) in envs {
40+
fmt_content.push_str(&format!(
41+
"{}=\"{}\" ",
42+
k.to_string_lossy(),
43+
v.to_string_lossy().replace('\"', "\\\"")
44+
));
4545
}
4646
}
4747
let raw_content = fmt_content.clone();

src/columns/involuntary_context_sw.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use crate::process::ProcessInfo;
22
use crate::util::bytify;
3-
use crate::{column_default, Column};
3+
use crate::{Column, column_default};
44
use std::cmp;
55
use std::collections::HashMap;
66

@@ -30,9 +30,8 @@ impl InvoluntaryContextSw {
3030
impl Column for InvoluntaryContextSw {
3131
fn add(&mut self, proc: &ProcessInfo) {
3232
let (fmt_content, raw_content) = if let Some(ref status) = proc.curr_status {
33-
if status.nonvoluntary_ctxt_switches.is_some()
34-
{
35-
let sw = status.nonvoluntary_ctxt_switches.unwrap();
33+
if let Some(nonvoluntary_ctxt_switches) = status.nonvoluntary_ctxt_switches {
34+
let sw = nonvoluntary_ctxt_switches;
3635
(bytify(sw), sw)
3736
} else {
3837
(String::new(), 0)

src/columns/read_bytes.rs

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use crate::process::ProcessInfo;
22
use crate::util::bytify;
3-
use crate::{column_default, Column};
3+
use crate::{Column, column_default};
44
use std::cmp;
55
use std::collections::HashMap;
66

@@ -29,12 +29,11 @@ impl ReadBytes {
2929
#[cfg(any(target_os = "linux", target_os = "android"))]
3030
impl Column for ReadBytes {
3131
fn add(&mut self, proc: &ProcessInfo) {
32-
let (fmt_content, raw_content) = if proc.curr_io.is_some() && proc.prev_io.is_some() {
32+
let (fmt_content, raw_content) = if let Some(curr_io) = proc.curr_io
33+
&& let Some(prev_io) = proc.prev_io
34+
{
3335
let interval_ms = proc.interval.as_secs() + u64::from(proc.interval.subsec_millis());
34-
let io = (proc.curr_io.as_ref().unwrap().read_bytes
35-
- proc.prev_io.as_ref().unwrap().read_bytes)
36-
* 1000
37-
/ interval_ms;
36+
let io = (curr_io.read_bytes - prev_io.read_bytes) * 1000 / interval_ms;
3837
(bytify(io), io)
3938
} else {
4039
(String::new(), 0)

src/columns/tcp_port.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
use crate::process::ProcessInfo;
21
use crate::Column;
2+
use crate::process::ProcessInfo;
33
#[cfg(target_os = "macos")]
44
use libproc::libproc::net_info::TcpSIState;
55
#[cfg(any(target_os = "linux", target_os = "android"))]
@@ -14,7 +14,7 @@ use std::net::{Ipv4Addr, Ipv6Addr, SocketAddr, SocketAddrV4, SocketAddrV6};
1414
use windows_sys::Win32::Foundation::{ERROR_INSUFFICIENT_BUFFER, NO_ERROR};
1515
#[cfg(target_os = "windows")]
1616
use windows_sys::Win32::NetworkManagement::IpHelper::{
17-
GetTcp6Table2, GetTcpTable2, MIB_TCP6TABLE2, MIB_TCPTABLE2, MIB_TCP_STATE, MIB_TCP_STATE_LISTEN,
17+
GetTcp6Table2, GetTcpTable2, MIB_TCP_STATE, MIB_TCP_STATE_LISTEN, MIB_TCP6TABLE2, MIB_TCPTABLE2,
1818
};
1919
#[cfg(target_os = "windows")]
2020
use windows_sys::Win32::Networking::WinSock::{ntohl, ntohs};
@@ -68,10 +68,10 @@ impl Column for TcpPort {
6868
for sock in &socks {
6969
let mut tcp_iter = self.tcp_entry.iter().chain(self.tcp6_entry.iter());
7070
let entry = tcp_iter.find(|&x| x.inode == *sock);
71-
if let Some(entry) = entry {
72-
if entry.state == TcpState::Listen {
73-
ports.push(entry.local_address.port());
74-
}
71+
if let Some(entry) = entry
72+
&& entry.state == TcpState::Listen
73+
{
74+
ports.push(entry.local_address.port());
7575
}
7676
}
7777
ports.sort_unstable();

src/columns/tree.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
use crate::process::ProcessInfo;
21
use crate::Column;
2+
use crate::process::ProcessInfo;
33
use std::cmp;
44
use std::collections::HashMap;
55

@@ -136,10 +136,10 @@ impl Column for Tree {
136136
for p in self.rev_tree.values() {
137137
if !self.rev_tree.contains_key(p) {
138138
root_pids.push(*p);
139-
} else if let Some(ppid) = self.rev_tree.get(p) {
140-
if *ppid == *p {
141-
root_pids.push(*p);
142-
}
139+
} else if let Some(ppid) = self.rev_tree.get(p)
140+
&& *ppid == *p
141+
{
142+
root_pids.push(*p);
143143
}
144144
}
145145
root_pids.sort_unstable();

src/columns/voluntary_context_sw.rs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use crate::process::ProcessInfo;
22
use crate::util::bytify;
3-
use crate::{column_default, Column};
3+
use crate::{Column, column_default};
44
use std::cmp;
55
use std::collections::HashMap;
66

@@ -30,9 +30,8 @@ impl VoluntaryContextSw {
3030
impl Column for VoluntaryContextSw {
3131
fn add(&mut self, proc: &ProcessInfo) {
3232
let (fmt_content, raw_content) = if let Some(ref status) = proc.curr_status {
33-
if status.voluntary_ctxt_switches.is_some()
34-
{
35-
let sw = status.voluntary_ctxt_switches.unwrap();
33+
if let Some(voluntary_ctxt_switches) = status.voluntary_ctxt_switches {
34+
let sw = voluntary_ctxt_switches;
3635
(bytify(sw), sw)
3736
} else {
3837
(String::new(), 0)
@@ -51,8 +50,7 @@ impl Column for VoluntaryContextSw {
5150
#[cfg(target_os = "freebsd")]
5251
impl Column for VoluntaryContextSw {
5352
fn add(&mut self, proc: &ProcessInfo) {
54-
let raw_content =
55-
proc.curr_proc.info.rusage.nvcsw as u64;
53+
let raw_content = proc.curr_proc.info.rusage.nvcsw as u64;
5654
let fmt_content = bytify(raw_content);
5755

5856
self.fmt_contents.insert(proc.pid, fmt_content);

src/columns/write_bytes.rs

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use crate::process::ProcessInfo;
22
use crate::util::bytify;
3-
use crate::{column_default, Column};
3+
use crate::{Column, column_default};
44
use std::cmp;
55
use std::collections::HashMap;
66

@@ -29,12 +29,11 @@ impl WriteBytes {
2929
#[cfg(any(target_os = "linux", target_os = "android"))]
3030
impl Column for WriteBytes {
3131
fn add(&mut self, proc: &ProcessInfo) {
32-
let (fmt_content, raw_content) = if proc.curr_io.is_some() && proc.prev_io.is_some() {
32+
let (fmt_content, raw_content) = if let Some(curr_io) = proc.curr_io
33+
&& let Some(prev_io) = proc.prev_io
34+
{
3335
let interval_ms = proc.interval.as_secs() + u64::from(proc.interval.subsec_millis());
34-
let io = (proc.curr_io.as_ref().unwrap().write_bytes
35-
- proc.prev_io.as_ref().unwrap().write_bytes)
36-
* 1000
37-
/ interval_ms;
36+
let io = (curr_io.write_bytes - prev_io.write_bytes) * 1000 / interval_ms;
3837
(bytify(io), io)
3938
} else {
4039
(String::new(), 0)

0 commit comments

Comments
 (0)