From 539fb0e6b30202bf36878c388f828fc3f37be00d Mon Sep 17 00:00:00 2001 From: Daniel McNab <36049421+DJMcNab@users.noreply.github.com> Date: Tue, 26 Apr 2022 20:47:16 +0000 Subject: [PATCH] Some minor cleanups of asset_server (#4604) # Objective - Code quality bad ## Solution - Code quality better - Using rust-analyzer's inline function and inline variable quick assists, I validated that the call to `AssetServer::new` is exactly the same code as the previous version. --- crates/bevy_asset/src/asset_server.rs | 22 ++-------------------- 1 file changed, 2 insertions(+), 20 deletions(-) diff --git a/crates/bevy_asset/src/asset_server.rs b/crates/bevy_asset/src/asset_server.rs index c7159f146d402..808f502faf56f 100644 --- a/crates/bevy_asset/src/asset_server.rs +++ b/crates/bevy_asset/src/asset_server.rs @@ -60,18 +60,11 @@ pub struct AssetServerInternal { } /// Loads assets from the filesystem on background threads +#[derive(Clone)] pub struct AssetServer { pub(crate) server: Arc, } -impl Clone for AssetServer { - fn clone(&self) -> Self { - Self { - server: self.server.clone(), - } - } -} - impl AssetServer { pub fn new(source_io: T, task_pool: TaskPool) -> Self { Self::with_boxed_io(Box::new(source_io), task_pool) @@ -629,18 +622,7 @@ mod test { fn setup(asset_path: impl AsRef) -> AssetServer { use crate::FileAssetIo; - AssetServer { - server: Arc::new(AssetServerInternal { - loaders: Default::default(), - extension_to_loader_index: Default::default(), - asset_sources: Default::default(), - asset_ref_counter: Default::default(), - handle_to_path: Default::default(), - asset_lifecycles: Default::default(), - task_pool: Default::default(), - asset_io: Box::new(FileAssetIo::new(asset_path, false)), - }), - } + AssetServer::new(FileAssetIo::new(asset_path, false), Default::default()) } #[test]