From f2aec407566eb70b52418959d22afd6c5c33474b Mon Sep 17 00:00:00 2001 From: gulag Date: Mon, 15 Apr 2024 19:28:11 -0400 Subject: [PATCH] tidying --- common/src/data/mod.rs | 3 ++- common/src/util.rs | 12 +++++------- dispatch/src/handlers.rs | 6 +++--- proto/build.rs | 4 +++- 4 files changed, 13 insertions(+), 12 deletions(-) diff --git a/common/src/data/mod.rs b/common/src/data/mod.rs index 6a5b94d..a5430bb 100644 --- a/common/src/data/mod.rs +++ b/common/src/data/mod.rs @@ -26,7 +26,8 @@ impl ExcelCollection { } } - pub fn table_count(&self) -> usize { + #[must_use] + pub const fn table_count(&self) -> usize { 1 } } diff --git a/common/src/util.rs b/common/src/util.rs index 685ebdd..a16530b 100644 --- a/common/src/util.rs +++ b/common/src/util.rs @@ -1,9 +1,7 @@ +#[must_use] pub fn load_or_create_config(path: &str, defaults: &str) -> String { - std::fs::read_to_string(path).map_or_else( - |_| { - std::fs::write(path, defaults).unwrap(); - defaults.to_string() - }, - |data| data, - ) + std::fs::read_to_string(path).unwrap_or_else(|_| { + std::fs::write(path, defaults).unwrap(); + defaults.to_string() + }) } diff --git a/dispatch/src/handlers.rs b/dispatch/src/handlers.rs index 4be1b58..447aca1 100644 --- a/dispatch/src/handlers.rs +++ b/dispatch/src/handlers.rs @@ -13,8 +13,8 @@ pub async fn query_dispatch() -> String { retcode: 0, region_list: CONFIGURATION .game_servers - .iter() - .map(|(_, c)| RegionInfo { + .values() + .map(|c| RegionInfo { name: c.name.clone(), title: c.title.clone(), env_type: c.env_type.clone(), @@ -46,7 +46,7 @@ pub async fn query_gateway( Gateserver { retcode: 0, ip: server_config.gateserver_ip.clone(), - port: server_config.gateserver_port as u32, + port: u32::from(server_config.gateserver_port), asset_bundle_url: version_config.asset_bundle_url.clone(), ex_resource_url: version_config.ex_resource_url.clone(), lua_url: version_config.lua_url.clone(), diff --git a/proto/build.rs b/proto/build.rs index 15f8eb3..dd0207b 100644 --- a/proto/build.rs +++ b/proto/build.rs @@ -1,6 +1,8 @@ +use std::path::Path; + pub fn main() { let proto_file = "StarRail.proto"; - if std::path::Path::new(proto_file).exists() { + if Path::new(proto_file).exists() { println!("cargo:rerun-if-changed={proto_file}"); prost_build::Config::new()