Skip to content

Commit a936479

Browse files
committed
w: fix CI and clippy warnings
1 parent e3a6517 commit a936479

File tree

1 file changed

+15
-17
lines changed

1 file changed

+15
-17
lines changed

src/uu/w/src/w.rs

Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,16 @@
33
// For the full copyright and license information, please view the LICENSE
44
// file that was distributed with this source code.
55

6+
use std::time::Duration;
7+
68
#[cfg(target_os = "linux")]
79
use chrono::Datelike;
810
use clap::crate_version;
911
use clap::{Arg, ArgAction, Command};
1012
#[cfg(target_os = "linux")]
1113
use libc::{sysconf, _SC_CLK_TCK};
12-
use std::process;
1314
#[cfg(target_os = "linux")]
14-
use std::{
15-
collections::HashMap,
16-
fs,
17-
path::Path,
18-
time::{Duration, SystemTime},
19-
};
15+
use std::{collections::HashMap, fs, path::Path, process, time::SystemTime};
2016
#[cfg(target_os = "linux")]
2117
use uucore::utmpx::Utmpx;
2218
use uucore::{error::UResult, format_usage, help_about, help_usage};
@@ -99,7 +95,11 @@ fn fetch_idle_time(tty: String) -> Result<Duration, std::io::Error> {
9995
}
10096
}
10197

102-
#[cfg(target_os = "linux")]
98+
#[cfg(not(target_os = "linux"))]
99+
fn fetch_idle_time(tty: String) -> Result<Duration, std::io::Error> {
100+
Ok(Duration::ZERO)
101+
}
102+
103103
fn format_time_elapsed(
104104
time: Duration,
105105
old_style: bool,
@@ -121,16 +121,14 @@ fn format_time_elapsed(
121121
t.num_seconds() % 60,
122122
if old_style { "m" } else { "" }
123123
))
124+
} else if old_style {
125+
Ok(String::new())
124126
} else {
125-
if old_style {
126-
Ok(format!(""))
127-
} else {
128-
Ok(format!(
129-
"{}.{:02}s",
130-
t.num_seconds() % 60,
131-
(t.num_milliseconds() % 1000) / 10
132-
))
133-
}
127+
Ok(format!(
128+
"{}.{:02}s",
129+
t.num_seconds() % 60,
130+
(t.num_milliseconds() % 1000) / 10
131+
))
134132
}
135133
}
136134

0 commit comments

Comments
 (0)