From 9a60751a901f568bdeb154c4115235d4f3a0f8b9 Mon Sep 17 00:00:00 2001 From: 魏曹先生 <1992414357@qq.com> Date: Fri, 20 Mar 2026 21:54:29 +0800 Subject: Apply clippy suggestions and improve code quality --- systems/vault/src/vault/config.rs | 20 +++++++++----------- systems/vault/src/vault/manager.rs | 6 ++++++ 2 files changed, 15 insertions(+), 11 deletions(-) (limited to 'systems/vault') diff --git a/systems/vault/src/vault/config.rs b/systems/vault/src/vault/config.rs index 329f78e..c552e15 100644 --- a/systems/vault/src/vault/config.rs +++ b/systems/vault/src/vault/config.rs @@ -1,3 +1,5 @@ +use std::path::Path; + use asset_system::{RWDataTest, rw::RWData}; use config_system::rw::{read_config, write_config}; use serde::{Deserialize, Serialize}; @@ -6,30 +8,26 @@ use serde::{Deserialize, Serialize}; pub struct VaultConfig {} impl RWData for VaultConfig { - async fn read( - path: &std::path::PathBuf, - ) -> Result { + async fn read(path: &Path) -> Result { let read_config = read_config(path).await; match read_config { Ok(config) => Ok(config), Err(e) => Err(asset_system::error::DataReadError::IoError( - std::io::Error::new(std::io::ErrorKind::Other, e), + std::io::Error::other(e), )), } } async fn write( data: VaultConfig, - path: &std::path::PathBuf, + path: &Path, ) -> Result<(), asset_system::error::DataWriteError> { let write_config = write_config(path, &data).await; match write_config { Ok(_) => Ok(()), - Err(e) => { - return Err(asset_system::error::DataWriteError::IoError( - std::io::Error::new(std::io::ErrorKind::Other, e), - )); - } + Err(e) => Err(asset_system::error::DataWriteError::IoError( + std::io::Error::other(e), + )), } } @@ -38,6 +36,6 @@ impl RWData for VaultConfig { } fn verify_data(data_a: VaultConfig, data_b: VaultConfig) -> bool { - &data_a == &data_b + data_a == data_b } } diff --git a/systems/vault/src/vault/manager.rs b/systems/vault/src/vault/manager.rs index bae26d4..249d020 100644 --- a/systems/vault/src/vault/manager.rs +++ b/systems/vault/src/vault/manager.rs @@ -8,6 +8,12 @@ pub struct VaultManager { space: Space, } +impl Default for VaultManager { + fn default() -> Self { + Self::new() + } +} + impl VaultManager { pub fn new() -> Self { VaultManager { -- cgit