summaryrefslogtreecommitdiffstats
path: root/vendor/sysinfo/examples/simple.rs
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/sysinfo/examples/simple.rs')
-rw-r--r--vendor/sysinfo/examples/simple.rs41
1 files changed, 29 insertions, 12 deletions
diff --git a/vendor/sysinfo/examples/simple.rs b/vendor/sysinfo/examples/simple.rs
index 43115b007..926cbca79 100644
--- a/vendor/sysinfo/examples/simple.rs
+++ b/vendor/sysinfo/examples/simple.rs
@@ -2,6 +2,7 @@
#![crate_type = "bin"]
#![allow(unused_must_use, non_upper_case_globals)]
+#![allow(clippy::manual_range_contains)]
extern crate sysinfo;
@@ -152,7 +153,7 @@ fn interpret_input(input: &str, sys: &mut System) -> bool {
let mut nb = 1i32;
for sig in signals {
- writeln!(&mut io::stdout(), "{:2}:{:?}", nb, sig);
+ writeln!(&mut io::stdout(), "{nb:2}:{sig:?}");
nb += 1;
}
}
@@ -172,14 +173,30 @@ fn interpret_input(input: &str, sys: &mut System) -> bool {
sys.global_cpu_info().cpu_usage()
);
for proc_ in sys.cpus() {
- writeln!(&mut io::stdout(), "{:?}", proc_);
+ writeln!(&mut io::stdout(), "{proc_:?}");
}
}
"memory" => {
- writeln!(&mut io::stdout(), "total memory: {} KB", sys.total_memory());
- writeln!(&mut io::stdout(), "used memory : {} KB", sys.used_memory());
- writeln!(&mut io::stdout(), "total swap : {} KB", sys.total_swap());
- writeln!(&mut io::stdout(), "used swap : {} KB", sys.used_swap());
+ writeln!(
+ &mut io::stdout(),
+ "total memory: {} KB",
+ sys.total_memory() / 1_000
+ );
+ writeln!(
+ &mut io::stdout(),
+ "used memory : {} KB",
+ sys.used_memory() / 1_000
+ );
+ writeln!(
+ &mut io::stdout(),
+ "total swap : {} KB",
+ sys.total_swap() / 1_000
+ );
+ writeln!(
+ &mut io::stdout(),
+ "used swap : {} KB",
+ sys.used_swap() / 1_000
+ );
}
"quit" | "exit" => return true,
"all" => {
@@ -228,19 +245,19 @@ fn interpret_input(input: &str, sys: &mut System) -> bool {
} else if let Ok(pid) = Pid::from_str(tmp[1]) {
match sys.process(pid) {
Some(p) => writeln!(&mut io::stdout(), "{:?}", *p),
- None => writeln!(&mut io::stdout(), "pid \"{:?}\" not found", pid),
+ None => writeln!(&mut io::stdout(), "pid \"{pid:?}\" not found"),
};
} else {
let proc_name = tmp[1];
for proc_ in sys.processes_by_name(proc_name) {
writeln!(&mut io::stdout(), "==== {} ====", proc_.name());
- writeln!(&mut io::stdout(), "{:?}", proc_);
+ writeln!(&mut io::stdout(), "{proc_:?}");
}
}
}
"temperature" => {
for component in sys.components() {
- writeln!(&mut io::stdout(), "{:?}", component);
+ writeln!(&mut io::stdout(), "{component:?}");
}
}
"network" => {
@@ -287,7 +304,7 @@ fn interpret_input(input: &str, sys: &mut System) -> bool {
if let Some(res) =
p.kill_with(*signals.get(signal as usize - 1).unwrap())
{
- writeln!(&mut io::stdout(), "kill: {}", res,);
+ writeln!(&mut io::stdout(), "kill: {res}");
} else {
writeln!(
&mut io::stdout(),
@@ -304,7 +321,7 @@ fn interpret_input(input: &str, sys: &mut System) -> bool {
}
"disks" => {
for disk in sys.disks() {
- writeln!(&mut io::stdout(), "{:?}", disk);
+ writeln!(&mut io::stdout(), "{disk:?}");
}
}
"users" => {
@@ -346,7 +363,7 @@ fn interpret_input(input: &str, sys: &mut System) -> bool {
.next()
{
if sys.refresh_process(pid) {
- writeln!(&mut io::stdout(), "Process `{}` updated successfully", pid);
+ writeln!(&mut io::stdout(), "Process `{pid}` updated successfully");
} else {
writeln!(
&mut io::stdout(),