Skip to content

Commit aadb7d6

Browse files
authored
clippy: fix struct_field_names lint (#10902)
1 parent 52237f2 commit aadb7d6

File tree

2 files changed

+22
-24
lines changed

2 files changed

+22
-24
lines changed

src/uucore/src/lib/features/entries.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,12 +147,14 @@ pub struct Passwd {
147147
/// AKA passwd.pw_dir
148148
pub user_dir: Option<String>,
149149
/// AKA passwd.pw_passwd
150+
#[expect(clippy::struct_field_names)]
150151
pub user_passwd: Option<String>,
151152
/// AKA passwd.pw_class
152153
#[cfg(any(target_os = "freebsd", target_vendor = "apple"))]
153154
pub user_access_class: Option<String>,
154155
/// AKA passwd.pw_change
155156
#[cfg(any(target_os = "freebsd", target_vendor = "apple"))]
157+
#[expect(clippy::struct_field_names)]
156158
pub passwd_change_time: time_t,
157159
/// AKA passwd.pw_expire
158160
#[cfg(any(target_os = "freebsd", target_vendor = "apple"))]

src/uucore/src/lib/features/uptime.rs

Lines changed: 20 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -207,41 +207,37 @@ pub enum OutputFormat {
207207
}
208208

209209
struct FormattedUptime {
210-
up_days: i64,
211-
up_hours: i64,
212-
up_mins: i64,
210+
days: i64,
211+
hours: i64,
212+
mins: i64,
213213
}
214214

215215
impl FormattedUptime {
216-
fn new(up_secs: i64) -> Self {
217-
let up_days = up_secs / 86400;
218-
let up_hours = (up_secs - (up_days * 86400)) / 3600;
219-
let up_mins = (up_secs - (up_days * 86400) - (up_hours * 3600)) / 60;
220-
221-
Self {
222-
up_days,
223-
up_hours,
224-
up_mins,
225-
}
216+
fn new(seconds: i64) -> Self {
217+
let days = seconds / 86400;
218+
let hours = (seconds - (days * 86400)) / 3600;
219+
let mins = (seconds - (days * 86400) - (hours * 3600)) / 60;
220+
221+
Self { days, hours, mins }
226222
}
227223

228224
fn get_human_readable_uptime(&self) -> String {
229225
translate!(
230226
"uptime-format",
231-
"days" => self.up_days,
232-
"time" => format!("{:02}:{:02}", self.up_hours, self.up_mins))
227+
"days" => self.days,
228+
"time" => format!("{:02}:{:02}", self.hours, self.mins))
233229
}
234230

235231
fn get_pretty_print_uptime(&self) -> String {
236232
let mut parts = Vec::new();
237-
if self.up_days > 0 {
238-
parts.push(translate!("uptime-format-pretty-day", "day" => self.up_days));
233+
if self.days > 0 {
234+
parts.push(translate!("uptime-format-pretty-day", "day" => self.days));
239235
}
240-
if self.up_hours > 0 {
241-
parts.push(translate!("uptime-format-pretty-hour", "hour" => self.up_hours));
236+
if self.hours > 0 {
237+
parts.push(translate!("uptime-format-pretty-hour", "hour" => self.hours));
242238
}
243-
if self.up_mins > 0 || parts.is_empty() {
244-
parts.push(translate!("uptime-format-pretty-min", "min" => self.up_mins));
239+
if self.mins > 0 || parts.is_empty() {
240+
parts.push(translate!("uptime-format-pretty-min", "min" => self.mins));
245241
}
246242
parts.join(", ")
247243
}
@@ -279,13 +275,13 @@ pub fn get_formatted_uptime(
279275
boot_time: Option<time_t>,
280276
output_format: OutputFormat,
281277
) -> UResult<String> {
282-
let up_secs = get_uptime(boot_time)?;
278+
let uptime = get_uptime(boot_time)?;
283279

284-
if up_secs < 0 {
280+
if uptime < 0 {
285281
Err(UptimeError::SystemUptime)?;
286282
}
287283

288-
let formatted_uptime = FormattedUptime::new(up_secs);
284+
let formatted_uptime = FormattedUptime::new(uptime);
289285

290286
match output_format {
291287
OutputFormat::HumanReadable => Ok(formatted_uptime.get_human_readable_uptime()),

0 commit comments

Comments
 (0)