Skip to content

Commit 2f67a72

Browse files
committed
Fix clippy warnings
1 parent 6baa45d commit 2f67a72

File tree

4 files changed

+38
-38
lines changed

4 files changed

+38
-38
lines changed

src/cli/dgpu.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ impl DynCommand for Command {
3838
.alias("set-rpm")
3939
.about("Set the dGPU runtime PM control")
4040
.arg(Arg::new("mode")
41-
.possible_values(&["on", "off"])
41+
.possible_values(["on", "off"])
4242
.required(true)
4343
.index(1))
4444
.display_order(4))
@@ -68,10 +68,10 @@ impl Command {
6868
.context("Failed to get device ID")?;
6969

7070
if !m.is_present("quiet") {
71-
println!("Vendor: {:04x}", vendor_id);
72-
println!("Device: {:04x}", device_id);
71+
println!("Vendor: {vendor_id:04x}");
72+
println!("Device: {device_id:04x}");
7373
} else {
74-
println!("{:04x}:{:04x}", vendor_id, device_id);
74+
println!("{vendor_id:04x}:{device_id:04x}");
7575
}
7676

7777
Ok(())
@@ -85,7 +85,7 @@ impl Command {
8585
let pstate = dgpu.get_power_state()
8686
.context("Failed to get device power state")?;
8787

88-
println!("{}", pstate);
88+
println!("{pstate}");
8989

9090
Ok(())
9191
}
@@ -98,7 +98,7 @@ impl Command {
9898
let mode = dgpu.get_runtime_pm()
9999
.context("Failed to get runtime PM mode")?;
100100

101-
println!("{}", mode);
101+
println!("{mode}");
102102

103103
Ok(())
104104
}
@@ -114,7 +114,7 @@ impl Command {
114114
.context("Failed to set runtime PM mode")?;
115115

116116
if !m.is_present("quiet") {
117-
println!("Discrete GPU runtime PM set to '{}'", mode);
117+
println!("Discrete GPU runtime PM set to '{mode}'");
118118
}
119119

120120
Ok(())

src/cli/dtx.rs

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ impl Command {
160160
let text = serde_json::to_string(&PrettyBaseInfo(info))
161161
.context("Failed to serialize data")?;
162162

163-
println!("{}", text);
163+
println!("{text}");
164164
}
165165

166166
Ok(())
@@ -172,7 +172,7 @@ impl Command {
172172
.get_device_mode()
173173
.context("Failed to get device mode")?;
174174

175-
println!("{}", mode);
175+
println!("{mode}");
176176
Ok(())
177177
}
178178

@@ -182,7 +182,7 @@ impl Command {
182182
.get_latch_status()
183183
.context("Failed to get latch status")?;
184184

185-
println!("{}", status);
185+
println!("{status}");
186186
Ok(())
187187
}
188188

@@ -207,7 +207,7 @@ impl Command {
207207
let text = serde_json::to_string(&PrettyEvent(event))
208208
.context("Failed to serialize data")?;
209209

210-
println!("{}", text);
210+
println!("{text}");
211211
}
212212
}
213213

@@ -369,9 +369,9 @@ impl std::fmt::Display for PrettyEvent {
369369
write!(f, "Cancel {{ Reason: ")?;
370370

371371
match reason {
372-
CancelReason::Hardware(err) => write!(f, "\"{}\"", err),
373-
CancelReason::Runtime(err) => write!(f, "\"{}\"", err),
374-
CancelReason::Unknown(err) => write!(f, "{:#04x}", err),
372+
CancelReason::Hardware(err) => write!(f, "\"{err}\""),
373+
CancelReason::Runtime(err) => write!(f, "\"{err}\""),
374+
CancelReason::Unknown(err) => write!(f, "{err:#04x}"),
375375
}?;
376376

377377
write!(f, " }}")
@@ -384,18 +384,18 @@ impl std::fmt::Display for PrettyEvent {
384384
BaseState::Detached => write!(f, "Detached"),
385385
BaseState::Attached => write!(f, "Attached"),
386386
BaseState::NotFeasible => write!(f, "NotFeasible"),
387-
BaseState::Unknown(x) => write!(f, "{:#04x}", x),
387+
BaseState::Unknown(x) => write!(f, "{x:#04x}"),
388388
}?;
389389

390390
write!(f, ", DeviceType: ")?;
391391

392392
match device_type {
393393
DeviceType::Hid => write!(f, "Hid"),
394394
DeviceType::Ssh => write!(f, "Ssh"),
395-
DeviceType::Unknown(x) => write!(f, "{:#04x}", x),
395+
DeviceType::Unknown(x) => write!(f, "{x:#04x}"),
396396
}?;
397397

398-
write!(f, ", Id: {:#04x} }}", id)
398+
write!(f, ", Id: {id:#04x} }}")
399399
},
400400

401401
Event::LatchStatus { status } => {
@@ -404,8 +404,8 @@ impl std::fmt::Display for PrettyEvent {
404404
match status {
405405
LatchStatus::Closed => write!(f, "Closed"),
406406
LatchStatus::Opened => write!(f, "Opened"),
407-
LatchStatus::Error(err) => write!(f, "\"Error: {}\"", err),
408-
LatchStatus::Unknown(x) => write!(f, "{:#04x}", x),
407+
LatchStatus::Error(err) => write!(f, "\"Error: {err}\""),
408+
LatchStatus::Unknown(x) => write!(f, "{x:#04x}"),
409409
}?;
410410

411411
write!(f, " }}")
@@ -418,14 +418,14 @@ impl std::fmt::Display for PrettyEvent {
418418
DeviceMode::Tablet => write!(f, "Tablet"),
419419
DeviceMode::Laptop => write!(f, "Laptop"),
420420
DeviceMode::Studio => write!(f, "Studio"),
421-
DeviceMode::Unknown(x) => write!(f, "{:#04x}", x),
421+
DeviceMode::Unknown(x) => write!(f, "{x:#04x}"),
422422
}?;
423423

424424
write!(f, " }}")
425425
},
426426

427427
Event::Unknown { code, data } => {
428-
write!(f, "Unknown {{ Code: {:#04x}, Data: {:02x?} }}", code, data)
428+
write!(f, "Unknown {{ Code: {code:#04x}, Data: {data:02x?} }}")
429429
},
430430
}
431431
}

src/cli/profile.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ impl Command {
5151
.context("Failed to get supported platform profiles")?;
5252

5353
if !supported.iter().any(|p| p == profile) {
54-
anyhow::bail!("Platform profile '{}' is not supported", profile);
54+
anyhow::bail!("Platform profile '{profile}' is not supported");
5555
}
5656

5757
let current_profile = dev.get()
@@ -62,11 +62,11 @@ impl Command {
6262
.context("Failed to set platform profile")?;
6363

6464
if !m.is_present("quiet") {
65-
println!("Platform profile set to '{}'", profile);
65+
println!("Platform profile set to '{profile}'");
6666
}
6767

6868
} else if !m.is_present("quiet") {
69-
println!("Platform profile already set to '{}', not changing", profile);
69+
println!("Platform profile already set to '{profile}', not changing");
7070
}
7171

7272
Ok(())
@@ -79,7 +79,7 @@ impl Command {
7979
let profile = dev.get()
8080
.context("Failed to get current platform profile")?;
8181

82-
println!("{}", profile);
82+
println!("{profile}");
8383
Ok(())
8484
}
8585

@@ -92,14 +92,14 @@ impl Command {
9292

9393
if !m.is_present("quiet") {
9494
for profile in supported {
95-
println!("{}", profile);
95+
println!("{profile}");
9696
}
9797

9898
} else {
9999
let text = serde_json::to_string(&supported)
100100
.context("Failed to serialize data")?;
101101

102-
println!("{}", text);
102+
println!("{text}");
103103
}
104104

105105
Ok(())

src/cli/status.rs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ impl DynCommand for Command {
2020
let stats = Stats::load();
2121

2222
if stats.available() {
23-
print!("{}", stats);
23+
print!("{stats}");
2424
Ok(())
2525
} else {
2626
anyhow::bail!("No devices found")
@@ -168,7 +168,7 @@ impl std::fmt::Display for ProfileStats {
168168
}
169169
}
170170

171-
writeln!(f, "Platform Profile: {}\n", profiles)
171+
writeln!(f, "Platform Profile: {profiles}\n")
172172
}
173173
}
174174

@@ -181,16 +181,16 @@ impl std::fmt::Display for DgpuStats {
181181
writeln!(f, "Discrete GPU:")?;
182182

183183
if let Some(vendor) = self.vendor {
184-
writeln!(f, " Vendor: {:04x}", vendor)?;
184+
writeln!(f, " Vendor: {vendor:04x}")?;
185185
}
186186
if let Some(device) = self.device {
187-
writeln!(f, " Device: {:04x}", device)?;
187+
writeln!(f, " Device: {device:04x}")?;
188188
}
189189
if let Some(power_state) = self.power_state {
190-
writeln!(f, " Power State: {}", power_state)?;
190+
writeln!(f, " Power State: {power_state}")?;
191191
}
192192
if let Some(runtime_pm) = self.runtime_pm {
193-
writeln!(f, " Runtime PM: {}", runtime_pm)?;
193+
writeln!(f, " Runtime PM: {runtime_pm}")?;
194194
}
195195

196196
writeln!(f)
@@ -206,19 +206,19 @@ impl std::fmt::Display for DtxStats {
206206
writeln!(f, "DTX:")?;
207207

208208
if let Some(device_mode) = self.device_mode {
209-
writeln!(f, " Device Mode: {}", device_mode)?;
209+
writeln!(f, " Device Mode: {device_mode}")?;
210210
}
211211
if let Some(base_state) = self.base_state {
212-
writeln!(f, " Base State: {}", base_state)?;
212+
writeln!(f, " Base State: {base_state}")?;
213213
}
214214
if let Some(base_type) = self.base_type {
215-
writeln!(f, " Base Type: {}", base_type)?;
215+
writeln!(f, " Base Type: {base_type}")?;
216216
}
217217
if let Some(base_id) = self.base_id {
218-
writeln!(f, " Base ID: {:#04x}", base_id)?;
218+
writeln!(f, " Base ID: {base_id:#04x}")?;
219219
}
220220
if let Some(latch_status) = self.latch_status {
221-
writeln!(f, " Latch Status: {}", latch_status)?;
221+
writeln!(f, " Latch Status: {latch_status}")?;
222222
}
223223

224224
writeln!(f)

0 commit comments

Comments
 (0)