chore: cargo clippy

This commit is contained in:
amizing25
2025-06-30 15:10:50 +07:00
parent 8d8686692e
commit bd40dc058f
7 changed files with 9398 additions and 505 deletions
+1 -1
View File
@@ -67,7 +67,7 @@ impl_from!(Relic, BattleRelic, |value| {
impl_from!(Relic, EquipRelic, |value| { impl_from!(Relic, EquipRelic, |value| {
EquipRelic { EquipRelic {
slot: value.get_slot(), r#type: value.get_slot(),
relic_unique_id: value.get_unique_id(), relic_unique_id: value.get_unique_id(),
} }
}); });
+4 -8
View File
@@ -129,10 +129,9 @@ impl Gateway {
if events if events
.iter() .iter()
.any(|p| p.path.file_name() == path.file_name()) .any(|p| p.path.file_name() == path.file_name())
{ && let Ok(metadata) = std::fs::metadata(path)
if let Ok(metadata) = std::fs::metadata(path) { && let Ok(modified) = metadata.modified()
if let Ok(modified) = metadata.modified() { && modified > last_modified {
if modified > last_modified {
last_modified = modified; last_modified = modified;
let mut session = session.write().await; let mut session = session.write().await;
@@ -142,11 +141,8 @@ impl Gateway {
tracing::info!("json updated"); tracing::info!("json updated");
} }
} }
}
}
}
} }
Err(e) => eprintln!("json watcher error: {:?}", e), Err(e) => eprintln!("json watcher error: {e:?}"),
} }
} }
_ = shutdown_rx.changed() => { _ = shutdown_rx.changed() => {
+2 -2
View File
@@ -118,7 +118,7 @@ pub async fn on_send_msg_cs_req(
session session
.send(RevcMsgScNotify { .send(RevcMsgScNotify {
msg_type: body.msg_type, msg_type: body.msg_type,
text: format!("Success change mc to {:#?}", mc), text: format!("Success change mc to {mc:#?}"),
emote: body.emote, emote: body.emote,
from_uid: SERVER_UID, from_uid: SERVER_UID,
to_uid: 25, to_uid: 25,
@@ -156,7 +156,7 @@ pub async fn on_send_msg_cs_req(
session session
.send(RevcMsgScNotify { .send(RevcMsgScNotify {
msg_type: body.msg_type, msg_type: body.msg_type,
text: format!("Success change march to {:#?}", march_type), text: format!("Success change march to {march_type:#?}"),
emote: body.emote, emote: body.emote,
from_uid: SERVER_UID, from_uid: SERVER_UID,
to_uid: 25, to_uid: 25,
+1 -1
View File
@@ -118,7 +118,7 @@ pub async fn on_get_scene_map_info_cs_req(
map_info map_info
.chest_unlock_progress_list .chest_unlock_progress_list
.push(ChestUnlockProgress { .push(ChestUnlockProgress {
chest_type: 0, r#type: 0,
total_chest_count: 25, total_chest_count: 25,
unlocked_chest_count: 25, unlocked_chest_count: 25,
}); });
+1 -5
View File
@@ -528,11 +528,7 @@ impl<Output> Kcp<Output> {
self.rx_srtt = rtt; self.rx_srtt = rtt;
self.rx_rttval = rtt / 2; self.rx_rttval = rtt / 2;
} else { } else {
let delta = if rtt > self.rx_srtt { let delta = rtt.abs_diff(self.rx_srtt);
rtt - self.rx_srtt
} else {
self.rx_srtt - rtt
};
self.rx_rttval = (3 * self.rx_rttval + delta) / 4; self.rx_rttval = (3 * self.rx_rttval + delta) / 4;
self.rx_srtt = ((7 * u64::from(self.rx_srtt) + u64::from(rtt)) / 8) as u32; self.rx_srtt = ((7 * u64::from(self.rx_srtt) + u64::from(rtt)) / 8) as u32;
if self.rx_srtt < 1 { if self.rx_srtt < 1 {
+9387 -485
View File
File diff suppressed because it is too large Load Diff
+2 -3
View File
@@ -31,7 +31,7 @@ pub async fn sr_tool_save(Json(json): Json<SrToolDataReq>) -> Json<SrToolDataRsp
Ok(json) => json, Ok(json) => json,
Err(err) => { Err(err) => {
return Json(SrToolDataRsp { return Json(SrToolDataRsp {
message: format!("malformed json: {}", err), message: format!("malformed json: {err}"),
status: 500, status: 500,
}); });
} }
@@ -43,8 +43,7 @@ pub async fn sr_tool_save(Json(json): Json<SrToolDataReq>) -> Json<SrToolDataRsp
if let Err(err) = fs::write(&path, json).await { if let Err(err) = fs::write(&path, json).await {
return Json(SrToolDataRsp { return Json(SrToolDataRsp {
message: format!( message: format!(
"failed to write freesr-data.json: {} at path: {:#?} env: {:#?}", "failed to write freesr-data.json: {err} at path: {path:#?} env: {env:#?}"
err, path, env
), ),
status: 500, status: 500,
}); });