Skip to content

Commit

Permalink
Some minor cleanups of asset_server (bevyengine#4604)
Browse files Browse the repository at this point in the history
# 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.
  • Loading branch information
DJMcNab authored and exjam committed May 22, 2022
1 parent 354cfc0 commit 539fb0e
Showing 1 changed file with 2 additions and 20 deletions.
22 changes: 2 additions & 20 deletions crates/bevy_asset/src/asset_server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,18 +60,11 @@ pub struct AssetServerInternal {
}

/// Loads assets from the filesystem on background threads
#[derive(Clone)]
pub struct AssetServer {
pub(crate) server: Arc<AssetServerInternal>,
}

impl Clone for AssetServer {
fn clone(&self) -> Self {
Self {
server: self.server.clone(),
}
}
}

impl AssetServer {
pub fn new<T: AssetIo>(source_io: T, task_pool: TaskPool) -> Self {
Self::with_boxed_io(Box::new(source_io), task_pool)
Expand Down Expand Up @@ -629,18 +622,7 @@ mod test {
fn setup(asset_path: impl AsRef<Path>) -> 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]
Expand Down

0 comments on commit 539fb0e

Please sign in to comment.