Skip to content

Commit 7898db2

Browse files
committed
Appease Clippy
1 parent 7929a0c commit 7898db2

13 files changed

Lines changed: 35 additions & 50 deletions

File tree

examples/http_listener.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ fn main() {
1515
let addr = format!("0.0.0.0:{}", args.port);
1616
let server = Server::http(&addr).expect("Failed to open HTTP Server");
1717

18-
println!("Listening on {}", addr);
18+
println!("Listening on {addr}");
1919

2020
for mut request in server.incoming_requests() {
2121
println!("Method: {:?}", request.method());
@@ -27,14 +27,14 @@ fn main() {
2727

2828
let mut content = String::new();
2929
if request.as_reader().read_to_string(&mut content).is_ok() {
30-
println!("Body:\n{}", content);
30+
println!("Body:\n{content}");
3131
} else {
3232
println!("Body: [binary data]");
3333
}
3434

3535
let response = Response::from_string("OK");
3636
if let Err(e) = request.respond(response) {
37-
eprintln!("Failed to send response: {}", e);
37+
eprintln!("Failed to send response: {e}");
3838
}
3939
}
4040
}

src/activities.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ impl ActivitiesFile {
4343
fn formatted_activities(activities: &BTreeMap<u8, String>) -> BTreeMap<u8, String> {
4444
let mut formatted = BTreeMap::new();
4545
for (index, name) in activities {
46-
formatted.insert(*index, format!("{index} - {}", name));
46+
formatted.insert(*index, format!("{index} - {name}"));
4747
}
4848
formatted
4949
}

src/app.rs

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ pub enum AppRx {
4949
UpdateReply(UpdateReply),
5050
}
5151

52+
#[allow(clippy::large_enum_variant)]
5253
#[derive(Debug)]
5354
pub enum DeviceUpdate {
5455
ConnectedEvent(String),
@@ -1108,8 +1109,7 @@ impl App {
11081109
VrcxPromptChoice::Yes => {
11091110
if let Err(e) = self.vrcx.create_shortcut() {
11101111
self.handle_error_update(ErrorPopup::Intermittent(format!(
1111-
"Failed to create VRCX shortcut: {}",
1112-
e
1112+
"Failed to create VRCX shortcut: {e}"
11131113
)));
11141114
} else {
11151115
// Commented out since the prompt is skipped if a shortcut exists,
@@ -1134,8 +1134,7 @@ impl App {
11341134
VrcxPromptChoice::OpenFolder => {
11351135
if let Err(e) = opener::open(self.vrcx.path().unwrap()) {
11361136
self.handle_error_update(ErrorPopup::UserMustDismiss(format!(
1137-
"Failed to open VRCX's startup folder! {}",
1138-
e
1137+
"Failed to open VRCX's startup folder! {e}"
11391138
)));
11401139
}
11411140
}
@@ -1185,11 +1184,7 @@ impl App {
11851184
// (We don't use the ScanFilter from btleplug to allow quicker connection to saved devices,
11861185
// and since it reports only "Unknown" names for some reason)
11871186
// TODO: Raise issue about it
1188-
if device
1189-
.services
1190-
.iter()
1191-
.any(|service| *service == HEART_RATE_SERVICE_UUID)
1192-
{
1187+
if device.services.contains(&HEART_RATE_SERVICE_UUID) {
11931188
self.discovered_devices.push(device.clone());
11941189
}
11951190
// This filter used to be in scan.rs, but doing it here

src/heart_rate/ble.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,8 +119,8 @@ impl BleMonitorActor {
119119

120120
error!("BLE Connection error: {}", e);
121121
broadcast!(broadcast_tx, ErrorPopup::Intermittent(format!(
122-
"BLE Connection error: {}",
123-
e
122+
"BLE Connection error: {e}"
123+
124124
)));
125125
// `NotConnected` is the "Device Unreachable" error
126126
// Weirdly enough, the Central manager doesn't get that error, only we do here at the HR level

src/heart_rate/websocket.rs

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ impl WebsocketActor {
4545
no_packet_timeout: Duration,
4646
) -> Result<(Self, SocketAddr), AppError> {
4747
let port = port_override.unwrap_or(websocket_settings.port);
48-
let host_addr = SocketAddrV4::from_str(&format!("0.0.0.0:{}", port))?;
48+
let host_addr = SocketAddrV4::from_str(&format!("0.0.0.0:{port}"))?;
4949

5050
let hr_status = HeartRateStatus {
5151
battery_level: BatteryLevel::NotReported,
@@ -82,8 +82,8 @@ impl WebsocketActor {
8282
}
8383
Err(err) => {
8484
broadcast!(broadcast_tx, ErrorPopup::UserMustDismiss(format!(
85-
"Handshake failed: {:?}",
86-
err
85+
"Handshake failed: {err:?}"
86+
8787
)));
8888
continue 'server;
8989
}
@@ -97,10 +97,10 @@ impl WebsocketActor {
9797
let mut stream = match ServerBuilder::new().accept(connection).await {
9898
Ok((_request, stream)) => stream,
9999
Err(err) => {
100-
error!("Handshake failed: {:?}", err);
100+
error!("Handshake failed: {err:?}",);
101101
broadcast!(
102102
broadcast_tx,
103-
ErrorPopup::UserMustDismiss(format!("Handshake failed: {:?}", err))
103+
ErrorPopup::UserMustDismiss(format!("Handshake failed: {err:?}"))
104104
);
105105
continue 'server;
106106
}
@@ -165,8 +165,7 @@ impl WebsocketActor {
165165
error!("Invalid message type: {:?}", msg);
166166
return Some((
167167
ErrorPopup::UserMustDismiss(format!(
168-
"Invalid message type (expected text): {:?}",
169-
msg
168+
"Invalid message type (expected text): {msg:?}"
170169
))
171170
.into(),
172171
true,
@@ -175,18 +174,16 @@ impl WebsocketActor {
175174
Some(Err(e)) => {
176175
error!("Error receiving message: {:?}", e);
177176
return Some((
178-
ErrorPopup::Intermittent(format!("Error receiving message: {:?}", e)).into(),
177+
ErrorPopup::Intermittent(format!("Error receiving message: {e:?}")).into(),
179178
false,
180179
));
181-
//break 'receiving;
182180
}
183181
None => {
184182
info!("Websocket client disconnected");
185183
return Some((
186184
ErrorPopup::Intermittent("Websocket client disconnected".to_string()).into(),
187185
false,
188186
));
189-
//break 'receiving;
190187
}
191188
};
192189

@@ -212,12 +209,10 @@ impl WebsocketActor {
212209

213210
Some((self.hr_status.clone().into(), true))
214211
} else {
215-
error!("Invalid heart rate message: {}", message);
216-
212+
error!("Invalid heart rate message: {message}");
217213
Some((
218214
AppUpdate::Error(ErrorPopup::Intermittent(format!(
219-
"Invalid heart rate message: {}",
220-
message
215+
"Invalid heart rate message: {message}"
221216
))),
222217
true,
223218
))

src/scan.rs

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -74,10 +74,9 @@ pub async fn bluetooth_event_thread(
7474
}
7575

7676
if let Err(e) = central.start_scan(ScanFilter::default()).await {
77-
error!("Scanning failure: {}", e);
77+
error!("Scanning failure: {e}");
7878
tx.send(DeviceUpdate::Error(ErrorPopup::Fatal(format!(
79-
"Scanning failure: {}",
80-
e
79+
"Scanning failure: {e}"
8180
))))
8281
.await
8382
.expect("Failed to send error message");
@@ -88,10 +87,9 @@ pub async fn bluetooth_event_thread(
8887
let mut events = match central.events().await {
8988
Ok(e) => e,
9089
Err(e) => {
91-
error!("BLE failure: {}", e);
90+
error!("BLE failure: {e}");
9291
tx.send(DeviceUpdate::Error(ErrorPopup::Fatal(format!(
93-
"BLE failure: {}",
94-
e
92+
"BLE failure: {e}"
9593
))))
9694
.await
9795
.expect("Failed to send error message");
@@ -112,10 +110,9 @@ pub async fn bluetooth_event_thread(
112110
} else if !scanning {
113111
info!("Resuming scan");
114112
if let Err(e) = central.start_scan(ScanFilter::default()).await {
115-
error!("Failed to resume scanning: {}", e);
113+
error!("Failed to resume scanning: {e}");
116114
tx.send(DeviceUpdate::Error(ErrorPopup::UserMustDismiss(format!(
117-
"Failed to resume scanning: {}",
118-
e
115+
"Failed to resume scanning: {e}"
119116
))))
120117
.await
121118
.expect("Failed to send error message");
@@ -231,10 +228,9 @@ pub async fn get_characteristics(tx: mpsc::Sender<DeviceUpdate>, peripheral: Dev
231228
}
232229
}
233230
Ok(Err(e)) => {
234-
error!("Characteristics: connection error: {}", e);
231+
error!("Characteristics: connection error: {e}");
235232
tx.send(DeviceUpdate::Error(ErrorPopup::Intermittent(format!(
236-
"Connection error: {}",
237-
e
233+
"Connection error: {e}"
238234
))))
239235
.await
240236
.expect("Failed to send error message");

src/ui.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ pub fn render(app: &mut App, f: &mut Frame) {
8888
} else {
8989
url.clone()
9090
};
91-
text.push_str(&format!("\nConnect to: {}", connection_info));
91+
text.push_str(&format!("\nConnect to: {connection_info}"));
9292
}
9393
let connecting_block = Paragraph::new(text)
9494
.alignment(Alignment::Center)

src/updates/mod.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ impl UpdateBackend {
211211
tmp_archive.flush().await?;
212212

213213
let bin_name = env!("CARGO_PKG_NAME");
214-
let bin_name = format!("{}{}", bin_name, EXE_SUFFIX);
214+
let bin_name = format!("{bin_name}{EXE_SUFFIX}");
215215
self.current_exe = Some(current_exe()?);
216216

217217
self_update::Extract::from_source(&tmp_archive_path)
@@ -393,8 +393,7 @@ impl App {
393393
info!("{url}");
394394
if let Err(e) = opener::open_browser(url) {
395395
self.handle_error_update(ErrorPopup::UserMustDismiss(format!(
396-
"Failed to open app repository! {}",
397-
e
396+
"Failed to open app repository! {e}"
398397
)));
399398
}
400399
}

src/utils.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ pub fn extract_manufacturer_data(manufacturer_data: &HashMap<u16, Vec<u8>>) -> M
1515
c = Some(key);
1616
let hex_string = value
1717
.iter()
18-
.map(|byte| format!("{:02X}", byte))
18+
.map(|byte| format!("{byte:02X}"))
1919
.collect::<Vec<String>>()
2020
.join(" ");
2121
hex_string.to_string()

src/vrcx/windows.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ async fn find_shortcut(startup_path: &Option<PathBuf>) -> Result<Option<PathBuf>
129129
#[instrument]
130130
fn check_shortcut(shortcut_path: &Path) -> Result<bool, AppError> {
131131
if let Some(ext) = shortcut_path.extension() {
132-
if ext.to_ascii_lowercase() != "lnk" {
132+
if !ext.eq_ignore_ascii_case("lnk") {
133133
return Ok(false);
134134
}
135135
} else {

0 commit comments

Comments
 (0)