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.
This commit is contained in:
Daniel McNab 2022-04-26 20:47:16 +00:00
parent 45d2c78949
commit bc7293e922

View File

@ -60,18 +60,11 @@ pub struct AssetServerInternal {
} }
/// Loads assets from the filesystem on background threads /// Loads assets from the filesystem on background threads
#[derive(Clone)]
pub struct AssetServer { pub struct AssetServer {
pub(crate) server: Arc<AssetServerInternal>, pub(crate) server: Arc<AssetServerInternal>,
} }
impl Clone for AssetServer {
fn clone(&self) -> Self {
Self {
server: self.server.clone(),
}
}
}
impl AssetServer { impl AssetServer {
pub fn new<T: AssetIo>(source_io: T, task_pool: TaskPool) -> Self { pub fn new<T: AssetIo>(source_io: T, task_pool: TaskPool) -> Self {
Self::with_boxed_io(Box::new(source_io), task_pool) Self::with_boxed_io(Box::new(source_io), task_pool)
@ -629,18 +622,7 @@ mod test {
fn setup(asset_path: impl AsRef<Path>) -> AssetServer { fn setup(asset_path: impl AsRef<Path>) -> AssetServer {
use crate::FileAssetIo; use crate::FileAssetIo;
AssetServer { AssetServer::new(FileAssetIo::new(asset_path, false), Default::default())
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)),
}),
}
} }
#[test] #[test]