diff options
| author | 魏曹先生 <1992414357@qq.com> | 2026-03-20 21:54:29 +0800 |
|---|---|---|
| committer | 魏曹先生 <1992414357@qq.com> | 2026-03-20 21:57:49 +0800 |
| commit | 9a60751a901f568bdeb154c4115235d4f3a0f8b9 (patch) | |
| tree | 65df323f6478bae51473a3d6471df39a596ce9c5 /systems/_asset/src/asset.rs | |
| parent | a9e5c086584d3e697188be7003f564e7e2137135 (diff) | |
Apply clippy suggestions and improve code quality
Diffstat (limited to 'systems/_asset/src/asset.rs')
| -rw-r--r-- | systems/_asset/src/asset.rs | 37 |
1 files changed, 15 insertions, 22 deletions
diff --git a/systems/_asset/src/asset.rs b/systems/_asset/src/asset.rs index c2b75e6..f452e2b 100644 --- a/systems/_asset/src/asset.rs +++ b/systems/_asset/src/asset.rs @@ -99,21 +99,17 @@ where .open(&lock_path) .await { - Ok(_) => { - return Ok(Handle { - _data_type: PhantomData, - writed: false, - asset_path: self.path.clone(), - lock_path, - temp_path, - }); - } + Ok(_) => Ok(Handle { + _data_type: PhantomData, + writed: false, + asset_path: self.path.clone(), + lock_path, + temp_path, + }), Err(e) if e.kind() == std::io::ErrorKind::AlreadyExists => { - return Err(HandleLockError::AssetLocked); - } - Err(e) => { - return Err(HandleLockError::IoError(e)); + Err(HandleLockError::AssetLocked) } + Err(e) => Err(HandleLockError::IoError(e)), } } @@ -231,7 +227,7 @@ where if self.writed { tokio::fs::rename(&from, &to) .await - .map_err(|e| DataApplyError::IoError(e))?; + .map_err(DataApplyError::IoError)?; } Ok(()) } @@ -350,18 +346,15 @@ async fn check_asset_path<D>(handle: &Handle<D>) -> Result<(), PrecheckFailed> where D: RWData<D>, { - if let Some(file_name) = handle.asset_path.file_name() { - if check_path(file_name).is_ok() { - return Ok(()); - } + if let Some(file_name) = handle.asset_path.file_name() + && check_path(file_name).is_ok() + { + return Ok(()); } Err(PrecheckFailed::AssetPathInvalid) } -async fn check_handle_is_cross_directory( - from: &PathBuf, - to: &PathBuf, -) -> Result<(), PrecheckFailed> { +async fn check_handle_is_cross_directory(from: &Path, to: &Path) -> Result<(), PrecheckFailed> { let from_parent = from.parent(); let to_parent = to.parent(); |
