From b1f07e37495cbefee495901deb380f8c7ac33993 Mon Sep 17 00:00:00 2001 From: Carter Anderson Date: Sat, 16 May 2020 00:27:30 -0700 Subject: [PATCH] cargo fmt --- crates/bevy_asset/src/asset_server.rs | 5 ++++- crates/bevy_asset/src/assets.rs | 5 +---- crates/bevy_asset/src/handle.rs | 3 +-- crates/bevy_asset/src/lib.rs | 15 ++++++++------- crates/bevy_gltf/src/lib.rs | 6 +++--- crates/bevy_gltf/src/loader.rs | 6 ++---- .../draw_targets/assigned_meshes_draw_target.rs | 8 ++++++-- crates/bevy_render/src/lib.rs | 9 ++++++--- crates/bevy_render/src/mesh.rs | 5 +---- .../entities_waiting_for_assets.rs | 12 +++++++++--- crates/bevy_render/src/render_resource/mod.rs | 4 ++-- crates/bevy_render/src/texture/mod.rs | 4 ++-- .../bevy_render/src/texture/png_texture_loader.rs | 8 +++----- crates/bevy_text/src/font_loader.rs | 2 +- crates/bevy_text/src/lib.rs | 4 +--- examples/3d/texture.rs | 4 +++- examples/app/plugin.rs | 2 +- examples/ui/text.rs | 4 +++- src/prelude.rs | 2 +- 19 files changed, 58 insertions(+), 50 deletions(-) diff --git a/crates/bevy_asset/src/asset_server.rs b/crates/bevy_asset/src/asset_server.rs index 1fc94320ef..ad34b31750 100644 --- a/crates/bevy_asset/src/asset_server.rs +++ b/crates/bevy_asset/src/asset_server.rs @@ -1,4 +1,7 @@ -use crate::{Assets, Handle, HandleId, LoadRequest, AssetLoadError, AssetLoadRequestHandler, AssetLoader, AssetPath}; +use crate::{ + AssetLoadError, AssetLoadRequestHandler, AssetLoader, AssetPath, Assets, Handle, HandleId, + LoadRequest, +}; use anyhow::Result; use legion::prelude::Resources; use std::{ diff --git a/crates/bevy_asset/src/assets.rs b/crates/bevy_asset/src/assets.rs index 9d62bf6c38..f2ace9b4bc 100644 --- a/crates/bevy_asset/src/assets.rs +++ b/crates/bevy_asset/src/assets.rs @@ -122,10 +122,7 @@ impl AddAsset for AppBuilder { T: Send + Sync + 'static, { self.init_resource::>() - .add_system_to_stage( - stage::POST_UPDATE, - Assets::::asset_event_system.system(), - ) + .add_system_to_stage(stage::POST_UPDATE, Assets::::asset_event_system.system()) .add_event::>() } diff --git a/crates/bevy_asset/src/handle.rs b/crates/bevy_asset/src/handle.rs index f761908502..f7a4886ba6 100644 --- a/crates/bevy_asset/src/handle.rs +++ b/crates/bevy_asset/src/handle.rs @@ -97,7 +97,6 @@ where } } - impl Hash for Handle { fn hash(&self, state: &mut H) { self.id.hash(state); @@ -160,4 +159,4 @@ where type_id: TypeId::of::(), } } -} \ No newline at end of file +} diff --git a/crates/bevy_asset/src/lib.rs b/crates/bevy_asset/src/lib.rs index 373836a3a0..f49e8c8dee 100644 --- a/crates/bevy_asset/src/lib.rs +++ b/crates/bevy_asset/src/lib.rs @@ -1,16 +1,16 @@ +mod asset_path; +mod asset_server; mod assets; mod handle; -mod loader; -mod asset_server; mod load_request; -mod asset_path; +mod loader; +pub use asset_path::*; +pub use asset_server::*; pub use assets::*; pub use handle::*; -pub use loader::*; -pub use asset_server::*; pub use load_request::*; -pub use asset_path::*; +pub use loader::*; use bevy_app::{AppBuilder, AppPlugin}; @@ -23,6 +23,7 @@ pub struct AssetPlugin; impl AppPlugin for AssetPlugin { fn build(&self, app: &mut AppBuilder) { - app.add_stage(stage::LOAD_ASSETS).init_resource::(); + app.add_stage(stage::LOAD_ASSETS) + .init_resource::(); } } diff --git a/crates/bevy_gltf/src/lib.rs b/crates/bevy_gltf/src/lib.rs index 77d2b7b8f3..1a14c76669 100644 --- a/crates/bevy_gltf/src/lib.rs +++ b/crates/bevy_gltf/src/lib.rs @@ -1,8 +1,8 @@ mod loader; pub use loader::*; -use bevy_app::{AppPlugin, AppBuilder}; -use bevy_asset::{AddAsset}; +use bevy_app::{AppBuilder, AppPlugin}; +use bevy_asset::AddAsset; #[derive(Default)] pub struct GltfPlugin; @@ -11,4 +11,4 @@ impl AppPlugin for GltfPlugin { fn build(&self, app: &mut AppBuilder) { app.add_asset_loader(GltfLoader); } -} \ No newline at end of file +} diff --git a/crates/bevy_gltf/src/loader.rs b/crates/bevy_gltf/src/loader.rs index 664756725e..bf6a6397dd 100644 --- a/crates/bevy_gltf/src/loader.rs +++ b/crates/bevy_gltf/src/loader.rs @@ -3,11 +3,11 @@ use bevy_render::{ pipeline::state_descriptors::PrimitiveTopology, }; +use anyhow::Result; use bevy_asset::{AssetLoader, AssetPath}; use gltf::{buffer::Source, iter, mesh::Mode}; use std::{fs, io, path::Path}; use thiserror::Error; -use anyhow::Result; #[derive(Clone)] pub struct GltfLoader; @@ -18,9 +18,7 @@ impl AssetLoader for GltfLoader { Ok(mesh) } fn extensions(&self) -> &[&str] { - static EXTENSIONS: &[&str] = &[ - "gltf" - ]; + static EXTENSIONS: &[&str] = &["gltf"]; EXTENSIONS } } diff --git a/crates/bevy_render/src/draw_target/draw_targets/assigned_meshes_draw_target.rs b/crates/bevy_render/src/draw_target/draw_targets/assigned_meshes_draw_target.rs index f257c80086..0ad94c3e06 100644 --- a/crates/bevy_render/src/draw_target/draw_targets/assigned_meshes_draw_target.rs +++ b/crates/bevy_render/src/draw_target/draw_targets/assigned_meshes_draw_target.rs @@ -7,7 +7,8 @@ use crate::{ pass::RenderPass, pipeline::{PipelineAssignments, PipelineDescriptor}, render_resource::{ - resource_name, EntityRenderResourceAssignments, RenderResourceAssignments, ResourceInfo, EntitiesWaitingForAssets, + resource_name, EntitiesWaitingForAssets, EntityRenderResourceAssignments, + RenderResourceAssignments, ResourceInfo, }, renderer::RenderContext, Renderable, @@ -46,7 +47,10 @@ impl DrawTarget for AssignedMeshesDrawTarget { .get(*assignment_id) .unwrap(); let renderable = world.get_component::(*entity).unwrap(); - if !renderable.is_visible || renderable.is_instanced || entities_waiting_for_assets.contains(entity) { + if !renderable.is_visible + || renderable.is_instanced + || entities_waiting_for_assets.contains(entity) + { continue; } diff --git a/crates/bevy_render/src/lib.rs b/crates/bevy_render/src/lib.rs index 93f7b59cfb..37dda30334 100644 --- a/crates/bevy_render/src/lib.rs +++ b/crates/bevy_render/src/lib.rs @@ -42,11 +42,11 @@ use self::{ use base_render_graph::{BaseRenderGraphBuilder, BaseRenderGraphConfig}; use bevy_app::{stage, AppBuilder, AppPlugin}; use bevy_asset::AddAsset; +use legion::prelude::IntoSystem; use mesh::mesh_resource_provider_system; use render_graph::RenderGraph; -use texture::PngTextureLoader; use render_resource::EntitiesWaitingForAssets; -use legion::prelude::IntoSystem; +use texture::PngTextureLoader; pub static RENDER_RESOURCE_STAGE: &str = "render_resource"; pub static RENDER_STAGE: &str = "render"; @@ -87,7 +87,10 @@ impl AppPlugin for RenderPlugin { .init_resource::() .add_system(entity_render_resource_assignments_system()) .init_system_to_stage(stage::POST_UPDATE, camera::camera_update_system) - .add_system_to_stage(stage::PRE_UPDATE, EntitiesWaitingForAssets::clear_system.system()) + .add_system_to_stage( + stage::PRE_UPDATE, + EntitiesWaitingForAssets::clear_system.system(), + ) .init_system_to_stage(RENDER_RESOURCE_STAGE, mesh_resource_provider_system); } } diff --git a/crates/bevy_render/src/mesh.rs b/crates/bevy_render/src/mesh.rs index 253e8bcfb7..f7b40697ad 100644 --- a/crates/bevy_render/src/mesh.rs +++ b/crates/bevy_render/src/mesh.rs @@ -403,10 +403,7 @@ pub fn mesh_resource_provider_system(resources: &mut Resources) -> Box>>() .with_query(<(Read>, Write)>::query()) .build( - move |_, - world, - (render_resource_context, meshes, mesh_events), - query| { + move |_, world, (render_resource_context, meshes, mesh_events), query| { let render_resources = &*render_resource_context.context; let changed_meshes = mesh_event_reader .iter(&mesh_events) diff --git a/crates/bevy_render/src/render_resource/entities_waiting_for_assets.rs b/crates/bevy_render/src/render_resource/entities_waiting_for_assets.rs index fe5b1a0c59..1442830e3a 100644 --- a/crates/bevy_render/src/render_resource/entities_waiting_for_assets.rs +++ b/crates/bevy_render/src/render_resource/entities_waiting_for_assets.rs @@ -1,5 +1,5 @@ use legion::prelude::{Entity, Res}; -use std::{sync::RwLock, collections::HashSet}; +use std::{collections::HashSet, sync::RwLock}; #[derive(Default)] pub struct EntitiesWaitingForAssets { @@ -8,11 +8,17 @@ pub struct EntitiesWaitingForAssets { impl EntitiesWaitingForAssets { pub fn add(&self, entity: Entity) { - self.entities.write().expect("RwLock poisoned").insert(entity); + self.entities + .write() + .expect("RwLock poisoned") + .insert(entity); } pub fn contains(&self, entity: &Entity) -> bool { - self.entities.read().expect("RwLock poisoned").contains(entity) + self.entities + .read() + .expect("RwLock poisoned") + .contains(entity) } pub fn clear(&self) { diff --git a/crates/bevy_render/src/render_resource/mod.rs b/crates/bevy_render/src/render_resource/mod.rs index 1560fe2017..61486e7f05 100644 --- a/crates/bevy_render/src/render_resource/mod.rs +++ b/crates/bevy_render/src/render_resource/mod.rs @@ -1,14 +1,14 @@ mod buffer; -mod entity_render_resource_assignments; mod entities_waiting_for_assets; +mod entity_render_resource_assignments; mod render_resource; mod render_resource_assignments; mod resource_info; pub mod resource_name; pub use buffer::*; -pub use entity_render_resource_assignments::*; pub use entities_waiting_for_assets::*; +pub use entity_render_resource_assignments::*; pub use render_resource::*; pub use render_resource_assignments::*; pub use resource_info::*; diff --git a/crates/bevy_render/src/texture/mod.rs b/crates/bevy_render/src/texture/mod.rs index 64218cf09b..effbb49f16 100644 --- a/crates/bevy_render/src/texture/mod.rs +++ b/crates/bevy_render/src/texture/mod.rs @@ -1,11 +1,11 @@ +mod png_texture_loader; mod sampler_descriptor; mod texture; mod texture_descriptor; mod texture_dimension; -mod png_texture_loader; +pub use png_texture_loader::*; pub use sampler_descriptor::*; pub use texture::*; pub use texture_descriptor::*; pub use texture_dimension::*; -pub use png_texture_loader::*; \ No newline at end of file diff --git a/crates/bevy_render/src/texture/png_texture_loader.rs b/crates/bevy_render/src/texture/png_texture_loader.rs index eeb3bd76f9..662f37f2bc 100644 --- a/crates/bevy_render/src/texture/png_texture_loader.rs +++ b/crates/bevy_render/src/texture/png_texture_loader.rs @@ -1,6 +1,6 @@ -use bevy_asset::{AssetPath, AssetLoader}; use super::Texture; use anyhow::Result; +use bevy_asset::{AssetLoader, AssetPath}; #[derive(Clone, Default)] pub struct PngTextureLoader; @@ -18,9 +18,7 @@ impl AssetLoader for PngTextureLoader { }) } fn extensions(&self) -> &[&str] { - static EXTENSIONS: &[&str] = &[ - "png" - ]; + static EXTENSIONS: &[&str] = &["png"]; EXTENSIONS } -} \ No newline at end of file +} diff --git a/crates/bevy_text/src/font_loader.rs b/crates/bevy_text/src/font_loader.rs index 76400f1e3e..e63f60e44c 100644 --- a/crates/bevy_text/src/font_loader.rs +++ b/crates/bevy_text/src/font_loader.rs @@ -1,6 +1,6 @@ use crate::Font; -use bevy_asset::{AssetLoader, AssetPath}; use anyhow::Result; +use bevy_asset::{AssetLoader, AssetPath}; #[derive(Clone)] pub struct FontLoader; diff --git a/crates/bevy_text/src/lib.rs b/crates/bevy_text/src/lib.rs index 0876954de8..4313d55fce 100644 --- a/crates/bevy_text/src/lib.rs +++ b/crates/bevy_text/src/lib.rs @@ -13,8 +13,6 @@ pub struct TextPlugin; impl AppPlugin for TextPlugin { fn build(&self, app: &mut AppBuilder) { - app - .add_asset::() - .add_asset_loader(FontLoader); + app.add_asset::().add_asset_loader(FontLoader); } } diff --git a/examples/3d/texture.rs b/examples/3d/texture.rs index 592917c076..963dbdad70 100644 --- a/examples/3d/texture.rs +++ b/examples/3d/texture.rs @@ -16,7 +16,9 @@ fn setup( mut materials: ResMut>, ) { // load a texture - let texture_handle = asset_server.load_sync(&mut textures, "assets/branding/bevy_logo_dark_big.png").unwrap(); + let texture_handle = asset_server + .load_sync(&mut textures, "assets/branding/bevy_logo_dark_big.png") + .unwrap(); let texture = textures.get(&texture_handle).unwrap(); let aspect = texture.aspect(); diff --git a/examples/app/plugin.rs b/examples/app/plugin.rs index 1f06462e4e..8997415bf3 100644 --- a/examples/app/plugin.rs +++ b/examples/app/plugin.rs @@ -14,7 +14,7 @@ fn main() { .run(); } -// This "print message plugin" prints a `message` every `wait_duration` +// This "print message plugin" prints a `message` every `wait_duration` pub struct PrintMessagePlugin { // Put your plugin configuration here wait_duration: Duration, diff --git a/examples/ui/text.rs b/examples/ui/text.rs index 1ff4da7bec..c5bafb79cc 100644 --- a/examples/ui/text.rs +++ b/examples/ui/text.rs @@ -14,7 +14,9 @@ fn setup( mut textures: ResMut>, mut materials: ResMut>, ) { - let font_handle = asset_server.load_sync(&mut fonts, "assets/fonts/FiraSans-Bold.ttf").unwrap(); + let font_handle = asset_server + .load_sync(&mut fonts, "assets/fonts/FiraSans-Bold.ttf") + .unwrap(); let font = fonts.get(&font_handle).unwrap(); let texture = font.render_text("Hello from Bevy!", Color::rgba(0.9, 0.9, 0.9, 1.0), 500, 60); diff --git a/src/prelude.rs b/src/prelude.rs index 80f617ba8d..5f0868058b 100644 --- a/src/prelude.rs +++ b/src/prelude.rs @@ -1,5 +1,5 @@ #[cfg(feature = "asset")] -pub use crate::asset::{AddAsset, AssetEvent, Assets, Handle, AssetServer}; +pub use crate::asset::{AddAsset, AssetEvent, AssetServer, Assets, Handle}; #[cfg(feature = "core")] pub use crate::core::{ time::Time,