From 196bde64e3769d564ce20e19f36be17f0f6d14cf Mon Sep 17 00:00:00 2001 From: Carter Anderson Date: Thu, 16 Jul 2020 17:23:50 -0700 Subject: [PATCH] cargo fmt --- crates/bevy_app/src/app.rs | 11 ++++++++--- crates/bevy_audio/src/audio_source.rs | 6 ++++-- crates/bevy_core/src/lib.rs | 2 +- crates/bevy_derive/src/modules.rs | 2 +- crates/bevy_ecs/src/into_system.rs | 2 +- crates/bevy_ecs/src/lib.rs | 6 +++--- crates/bevy_ecs/src/parallel_executor.rs | 3 ++- crates/bevy_ecs/src/resource_query.rs | 6 +++++- crates/bevy_ecs/src/schedule.rs | 5 +++-- crates/bevy_ecs/src/system.rs | 7 ++++--- crates/bevy_math/src/lib.rs | 2 +- crates/bevy_pbr/src/light.rs | 2 +- crates/bevy_render/src/camera/camera.rs | 2 +- crates/bevy_render/src/camera/projection.rs | 2 +- crates/bevy_render/src/color.rs | 2 +- .../bevy_sprite/src/dynamic_texture_atlas_builder.rs | 2 +- crates/bevy_sprite/src/lib.rs | 2 +- crates/bevy_sprite/src/sprite.rs | 2 +- crates/bevy_sprite/src/texture_atlas.rs | 2 +- crates/bevy_sprite/src/texture_atlas_builder.rs | 2 +- crates/bevy_text/src/draw.rs | 2 +- crates/bevy_text/src/font.rs | 2 +- crates/bevy_text/src/font_atlas.rs | 2 +- crates/bevy_text/src/font_atlas_set.rs | 2 +- crates/bevy_transform/src/hierarchy/mod.rs | 2 +- crates/bevy_transform/src/local_transform_systems.rs | 4 ++-- crates/bevy_ui/src/node.rs | 2 +- crates/bevy_ui/src/ui_update_system.rs | 2 +- crates/bevy_wgpu/src/lib.rs | 2 +- crates/bevy_winit/src/lib.rs | 2 +- src/prelude.rs | 6 ++---- 31 files changed, 55 insertions(+), 43 deletions(-) diff --git a/crates/bevy_app/src/app.rs b/crates/bevy_app/src/app.rs index 3d3122fe2f..02402e8878 100644 --- a/crates/bevy_app/src/app.rs +++ b/crates/bevy_app/src/app.rs @@ -1,5 +1,5 @@ use super::AppBuilder; -use bevy_ecs::{Resources, Schedule, World, ParallelExecutor}; +use bevy_ecs::{ParallelExecutor, Resources, Schedule, World}; #[derive(Default)] pub struct App { @@ -19,12 +19,17 @@ impl App { pub fn update(&mut self) { self.schedule.initialize(&mut self.resources); - self.executor.run(&mut self.schedule, &mut self.world, &mut self.resources); + self.executor + .run(&mut self.schedule, &mut self.world, &mut self.resources); } pub fn run(mut self) { self.startup_schedule.initialize(&mut self.resources); - self.startup_executor.run(&mut self.startup_schedule, &mut self.world, &mut self.resources); + self.startup_executor.run( + &mut self.startup_schedule, + &mut self.world, + &mut self.resources, + ); if let Some(run) = self.runner.take() { run(self) } diff --git a/crates/bevy_audio/src/audio_source.rs b/crates/bevy_audio/src/audio_source.rs index 5e4a734d5b..8a7060def4 100644 --- a/crates/bevy_audio/src/audio_source.rs +++ b/crates/bevy_audio/src/audio_source.rs @@ -1,6 +1,6 @@ use anyhow::Result; use bevy_asset::AssetLoader; -use std::{sync::Arc, path::Path}; +use std::{path::Path, sync::Arc}; #[derive(Clone)] pub struct AudioSource { @@ -18,7 +18,9 @@ pub struct Mp3Loader; impl AssetLoader for Mp3Loader { fn from_bytes(&self, _asset_path: &Path, bytes: Vec) -> Result { - Ok(AudioSource { bytes: Arc::new(bytes) }) + Ok(AudioSource { + bytes: Arc::new(bytes), + }) } fn extensions(&self) -> &[&str] { static EXTENSIONS: &[&str] = &["mp3"]; diff --git a/crates/bevy_core/src/lib.rs b/crates/bevy_core/src/lib.rs index 0778157daa..a2a2e1beac 100644 --- a/crates/bevy_core/src/lib.rs +++ b/crates/bevy_core/src/lib.rs @@ -4,9 +4,9 @@ pub mod time; use bevy_app::{stage, AppBuilder, AppPlugin}; use bevy_ecs::IntoQuerySystem; +use bevy_math::{Mat3, Mat4, Quat, Vec2, Vec3}; use bevy_type_registry::RegisterType; use time::{time_system, timer_system, Time, Timer}; -use bevy_math::{Vec3, Vec2, Mat3, Mat4, Quat}; #[derive(Default)] pub struct CorePlugin; diff --git a/crates/bevy_derive/src/modules.rs b/crates/bevy_derive/src/modules.rs index 7258f2cb38..92d032d456 100644 --- a/crates/bevy_derive/src/modules.rs +++ b/crates/bevy_derive/src/modules.rs @@ -47,7 +47,7 @@ pub fn get_modules(attributes: &[Attribute]) -> Modules { if attribute.path.get_ident().as_ref().unwrap().to_string() == AS_CRATE_ATTRIBUTE_NAME { let value = attribute.tokens.to_string(); if &value[1..value.len() - 1] == modules.bevy_render { - modules.bevy_render = "crate".to_string(); + modules.bevy_render = "crate".to_string(); } } } diff --git a/crates/bevy_ecs/src/into_system.rs b/crates/bevy_ecs/src/into_system.rs index 53e2b7e001..00e241294d 100644 --- a/crates/bevy_ecs/src/into_system.rs +++ b/crates/bevy_ecs/src/into_system.rs @@ -49,7 +49,7 @@ where fn archetype_access(&self) -> &ArchetypeAccess { &self.archetype_access } - + fn resource_access(&self) -> &TypeAccess { &self.resource_access } diff --git a/crates/bevy_ecs/src/lib.rs b/crates/bevy_ecs/src/lib.rs index 6115994cea..cdd9f35892 100644 --- a/crates/bevy_ecs/src/lib.rs +++ b/crates/bevy_ecs/src/lib.rs @@ -1,8 +1,8 @@ pub use hecs::{Query as HecsQuery, *}; mod commands; -mod parallel_executor; mod into_system; +mod parallel_executor; #[cfg(feature = "profiler")] pub mod profiler; pub mod resource_query; @@ -13,9 +13,9 @@ mod world_builder; pub use commands::{Commands, CommandsInternal}; pub use into_system::{IntoForEachSystem, IntoQuerySystem, IntoThreadLocalSystem, Query}; +pub use parallel_executor::ParallelExecutor; pub use resource_query::{FetchResource, Local, Res, ResMut, ResourceQuery}; pub use resources::{FromResources, Resource, Resources}; pub use schedule::Schedule; -pub use parallel_executor::ParallelExecutor; -pub use system::{System, SystemId, TypeAccess, ArchetypeAccess}; +pub use system::{ArchetypeAccess, System, SystemId, TypeAccess}; pub use world_builder::{WorldBuilder, WorldBuilderSource}; diff --git a/crates/bevy_ecs/src/parallel_executor.rs b/crates/bevy_ecs/src/parallel_executor.rs index 9d3aa30584..6bf22c7fab 100644 --- a/crates/bevy_ecs/src/parallel_executor.rs +++ b/crates/bevy_ecs/src/parallel_executor.rs @@ -29,7 +29,8 @@ impl ParallelExecutor { if schedule_changed { self.stages.clear(); - self.stages.resize_with(schedule.stage_order.len(), || ExecutorStage::default()); + self.stages + .resize_with(schedule.stage_order.len(), || ExecutorStage::default()); } for (stage_index, stage_name) in schedule.stage_order.iter().enumerate() { diff --git a/crates/bevy_ecs/src/resource_query.rs b/crates/bevy_ecs/src/resource_query.rs index 73cb5755bd..73b4bd5353 100644 --- a/crates/bevy_ecs/src/resource_query.rs +++ b/crates/bevy_ecs/src/resource_query.rs @@ -1,4 +1,8 @@ -use crate::{resources::FromResources, system::{TypeAccess, SystemId}, Archetype, Component, Resources}; +use crate::{ + resources::FromResources, + system::{SystemId, TypeAccess}, + Archetype, Component, Resources, +}; use core::{ any::TypeId, ops::{Deref, DerefMut}, diff --git a/crates/bevy_ecs/src/schedule.rs b/crates/bevy_ecs/src/schedule.rs index 02a7723e73..87f29747e7 100644 --- a/crates/bevy_ecs/src/schedule.rs +++ b/crates/bevy_ecs/src/schedule.rs @@ -4,7 +4,8 @@ use crate::{ }; use std::{ borrow::Cow, - collections::{HashMap, HashSet}, sync::{Mutex, Arc}, + collections::{HashMap, HashSet}, + sync::{Arc, Mutex}, }; #[derive(Default)] @@ -151,4 +152,4 @@ impl Schedule { pub fn generation(&self) -> usize { self.generation } -} \ No newline at end of file +} diff --git a/crates/bevy_ecs/src/system.rs b/crates/bevy_ecs/src/system.rs index c1ff22d881..bfcdaaf532 100644 --- a/crates/bevy_ecs/src/system.rs +++ b/crates/bevy_ecs/src/system.rs @@ -99,9 +99,9 @@ impl TypeAccess { #[cfg(test)] mod tests { - use super::{TypeAccess, ArchetypeAccess}; + use super::{ArchetypeAccess, TypeAccess}; + use crate::{FetchResource, Res, ResMut, ResourceQuery}; use hecs::World; - use crate::{ResourceQuery, FetchResource, Res, ResMut}; use std::any::TypeId; struct A; @@ -136,7 +136,8 @@ mod tests { #[test] fn resource_query_access() { - let access = <<(Res, ResMut, Res) as ResourceQuery>::Fetch as FetchResource>::access(); + let access = + <<(Res, ResMut, Res) as ResourceQuery>::Fetch as FetchResource>::access(); let mut expected_access = TypeAccess::default(); expected_access.immutable.insert(TypeId::of::()); expected_access.immutable.insert(TypeId::of::()); diff --git a/crates/bevy_math/src/lib.rs b/crates/bevy_math/src/lib.rs index 5b858286e4..9ce2e0d6bf 100644 --- a/crates/bevy_math/src/lib.rs +++ b/crates/bevy_math/src/lib.rs @@ -1,4 +1,4 @@ mod face_toward; pub use face_toward::*; -pub use glam::*; \ No newline at end of file +pub use glam::*; diff --git a/crates/bevy_pbr/src/light.rs b/crates/bevy_pbr/src/light.rs index d763bdb421..402a37cbe8 100644 --- a/crates/bevy_pbr/src/light.rs +++ b/crates/bevy_pbr/src/light.rs @@ -1,8 +1,8 @@ use bevy_core::bytes::Byteable; +use bevy_math::Mat4; use bevy_property::Properties; use bevy_render::{CameraProjection, Color, PerspectiveProjection}; use bevy_transform::components::Translation; -use bevy_math::Mat4; use std::ops::Range; #[derive(Properties)] diff --git a/crates/bevy_render/src/camera/camera.rs b/crates/bevy_render/src/camera/camera.rs index 5a2163db37..9cc5755165 100644 --- a/crates/bevy_render/src/camera/camera.rs +++ b/crates/bevy_render/src/camera/camera.rs @@ -1,9 +1,9 @@ use crate::CameraProjection; use bevy_app::{EventReader, Events}; use bevy_ecs::{Component, Local, Query, Res}; +use bevy_math::Mat4; use bevy_property::Properties; use bevy_window::{WindowCreated, WindowReference, WindowResized, Windows}; -use bevy_math::Mat4; #[derive(Default, Debug, Properties)] pub struct Camera { diff --git a/crates/bevy_render/src/camera/projection.rs b/crates/bevy_render/src/camera/projection.rs index 98feab2265..43053a5d1a 100644 --- a/crates/bevy_render/src/camera/projection.rs +++ b/crates/bevy_render/src/camera/projection.rs @@ -1,5 +1,5 @@ -use bevy_property::{Properties, Property}; use bevy_math::Mat4; +use bevy_property::{Properties, Property}; use serde::{Deserialize, Serialize}; pub trait CameraProjection { diff --git a/crates/bevy_render/src/color.rs b/crates/bevy_render/src/color.rs index ffa045802b..89cb123beb 100644 --- a/crates/bevy_render/src/color.rs +++ b/crates/bevy_render/src/color.rs @@ -5,8 +5,8 @@ use crate::{ }; use bevy_asset::Handle; use bevy_core::bytes::{Byteable, Bytes}; -use bevy_property::Property; use bevy_math::Vec4; +use bevy_property::Property; use serde::{Deserialize, Serialize}; use std::ops::{Add, AddAssign}; diff --git a/crates/bevy_sprite/src/dynamic_texture_atlas_builder.rs b/crates/bevy_sprite/src/dynamic_texture_atlas_builder.rs index c0ef9d6d50..13c643d170 100644 --- a/crates/bevy_sprite/src/dynamic_texture_atlas_builder.rs +++ b/crates/bevy_sprite/src/dynamic_texture_atlas_builder.rs @@ -1,7 +1,7 @@ use crate::{Rect, TextureAtlas}; use bevy_asset::{Assets, Handle}; -use bevy_render::texture::Texture; use bevy_math::Vec2; +use bevy_render::texture::Texture; use guillotiere::{size2, AllocId, Allocation, AtlasAllocator}; use std::collections::HashMap; diff --git a/crates/bevy_sprite/src/lib.rs b/crates/bevy_sprite/src/lib.rs index 4d4057c8ea..3759826acd 100644 --- a/crates/bevy_sprite/src/lib.rs +++ b/crates/bevy_sprite/src/lib.rs @@ -19,12 +19,12 @@ pub use texture_atlas_builder::*; use bevy_app::{stage, AppBuilder, AppPlugin}; use bevy_asset::{AddAsset, Assets, Handle}; use bevy_ecs::IntoQuerySystem; +use bevy_math::Vec2; use bevy_render::{ mesh::{shape, Mesh}, render_graph::RenderGraph, shader::asset_shader_defs_system, }; -use bevy_math::Vec2; use sprite::sprite_system; #[derive(Default)] diff --git a/crates/bevy_sprite/src/sprite.rs b/crates/bevy_sprite/src/sprite.rs index 1d4856b40c..b05c58ccdf 100644 --- a/crates/bevy_sprite/src/sprite.rs +++ b/crates/bevy_sprite/src/sprite.rs @@ -2,11 +2,11 @@ use crate::ColorMaterial; use bevy_asset::{Assets, Handle}; use bevy_core::bytes::Byteable; use bevy_ecs::{Query, Res}; +use bevy_math::Vec2; use bevy_render::{ render_resource::{RenderResource, RenderResources}, texture::Texture, }; -use bevy_math::Vec2; #[repr(C)] #[derive(Default, RenderResources, RenderResource)] diff --git a/crates/bevy_sprite/src/texture_atlas.rs b/crates/bevy_sprite/src/texture_atlas.rs index d8f4851b95..9268ad8a51 100644 --- a/crates/bevy_sprite/src/texture_atlas.rs +++ b/crates/bevy_sprite/src/texture_atlas.rs @@ -1,12 +1,12 @@ use crate::Rect; use bevy_asset::Handle; use bevy_core::bytes::Bytes; +use bevy_math::Vec2; use bevy_render::{ render_resource::{RenderResource, RenderResources}, texture::Texture, Color, }; -use bevy_math::Vec2; use std::collections::HashMap; #[derive(RenderResources)] diff --git a/crates/bevy_sprite/src/texture_atlas_builder.rs b/crates/bevy_sprite/src/texture_atlas_builder.rs index 77780903ff..cebbf6463c 100644 --- a/crates/bevy_sprite/src/texture_atlas_builder.rs +++ b/crates/bevy_sprite/src/texture_atlas_builder.rs @@ -1,7 +1,7 @@ use crate::{Rect, TextureAtlas}; use bevy_asset::{Assets, Handle}; -use bevy_render::texture::Texture; use bevy_math::Vec2; +use bevy_render::texture::Texture; use rectangle_pack::{ contains_smallest_box, pack_rects, volume_heuristic, GroupedRectsToPlace, PackedLocation, RectToInsert, TargetBin, diff --git a/crates/bevy_text/src/draw.rs b/crates/bevy_text/src/draw.rs index c6e212977d..bf6f5758e7 100644 --- a/crates/bevy_text/src/draw.rs +++ b/crates/bevy_text/src/draw.rs @@ -1,6 +1,7 @@ use crate::{Font, FontAtlasSet}; use ab_glyph::{Glyph, PxScale, ScaleFont}; use bevy_asset::Assets; +use bevy_math::{Mat4, Vec3}; use bevy_render::{ draw::{Draw, DrawContext, DrawError, Drawable}, mesh, @@ -12,7 +13,6 @@ use bevy_render::{ Color, }; use bevy_sprite::{TextureAtlas, TextureAtlasSprite}; -use bevy_math::{Mat4, Vec3}; pub struct TextStyle { pub font_size: f32, diff --git a/crates/bevy_text/src/font.rs b/crates/bevy_text/src/font.rs index bf39aa4b74..c63854c086 100644 --- a/crates/bevy_text/src/font.rs +++ b/crates/bevy_text/src/font.rs @@ -1,6 +1,6 @@ use ab_glyph::{FontVec, Glyph, InvalidFont, OutlinedGlyph, Point, PxScale, ScaleFont}; -use bevy_render::{texture::Texture, Color}; use bevy_math::Vec2; +use bevy_render::{texture::Texture, Color}; pub struct Font { pub font: FontVec, diff --git a/crates/bevy_text/src/font_atlas.rs b/crates/bevy_text/src/font_atlas.rs index f30bcd668b..ce517bb703 100644 --- a/crates/bevy_text/src/font_atlas.rs +++ b/crates/bevy_text/src/font_atlas.rs @@ -1,7 +1,7 @@ use bevy_asset::{Assets, Handle}; +use bevy_math::Vec2; use bevy_render::texture::Texture; use bevy_sprite::{DynamicTextureAtlasBuilder, TextureAtlas}; -use bevy_math::Vec2; use std::collections::HashMap; pub struct FontAtlas { diff --git a/crates/bevy_text/src/font_atlas_set.rs b/crates/bevy_text/src/font_atlas_set.rs index 62d57e88b6..d1aafbd2f8 100644 --- a/crates/bevy_text/src/font_atlas_set.rs +++ b/crates/bevy_text/src/font_atlas_set.rs @@ -2,9 +2,9 @@ use crate::{Font, FontAtlas}; use ab_glyph::ScaleFont; use bevy_asset::{Assets, Handle}; use bevy_core::float_ord::FloatOrd; +use bevy_math::Vec2; use bevy_render::texture::Texture; use bevy_sprite::TextureAtlas; -use bevy_math::Vec2; use std::collections::HashMap; // work around rust's f32 order/hash limitations diff --git a/crates/bevy_transform/src/hierarchy/mod.rs b/crates/bevy_transform/src/hierarchy/mod.rs index ebc4372d77..b2fb6d4ce3 100644 --- a/crates/bevy_transform/src/hierarchy/mod.rs +++ b/crates/bevy_transform/src/hierarchy/mod.rs @@ -6,4 +6,4 @@ mod world_child_builder; pub use child_builder::*; pub use hierarchy::*; pub use hierarchy_maintenance_system::*; -pub use world_child_builder::*; \ No newline at end of file +pub use world_child_builder::*; diff --git a/crates/bevy_transform/src/local_transform_systems.rs b/crates/bevy_transform/src/local_transform_systems.rs index dae2b26e0f..b8a76e5c9c 100644 --- a/crates/bevy_transform/src/local_transform_systems.rs +++ b/crates/bevy_transform/src/local_transform_systems.rs @@ -2,7 +2,7 @@ use crate::components::*; use bevy_ecs::{IntoQuerySystem, Query, System, Without}; -use bevy_math::{Vec3, Mat4, Quat}; +use bevy_math::{Mat4, Quat, Vec3}; // TODO: "on changed" for all of these systems pub fn local_transform_translation_system( @@ -178,8 +178,8 @@ pub fn local_transform_systems() -> Vec> { #[cfg(test)] mod test { use super::*; - use bevy_math::{Mat4, Quat, Vec3}; use bevy_ecs::{Resources, Schedule, World}; + use bevy_math::{Mat4, Quat, Vec3}; #[test] fn correct_local_transformation() { diff --git a/crates/bevy_ui/src/node.rs b/crates/bevy_ui/src/node.rs index 57294eaa9e..f30bc6aa53 100644 --- a/crates/bevy_ui/src/node.rs +++ b/crates/bevy_ui/src/node.rs @@ -1,7 +1,7 @@ use super::{Anchors, Margins}; +use bevy_math::{Vec2, Vec3}; use bevy_render::render_resource::RenderResources; use bevy_transform::prelude::Translation; -use bevy_math::{Vec2, Vec3}; #[derive(Debug, Clone)] enum MarginGrowDirection { diff --git a/crates/bevy_ui/src/ui_update_system.rs b/crates/bevy_ui/src/ui_update_system.rs index f3efe42bea..39cf798d6c 100644 --- a/crates/bevy_ui/src/ui_update_system.rs +++ b/crates/bevy_ui/src/ui_update_system.rs @@ -1,11 +1,11 @@ use super::Node; use bevy_ecs::{Entity, Query, Res, Without}; +use bevy_math::Vec2; use bevy_transform::{ hierarchy, prelude::{Children, Parent, Translation}, }; use bevy_window::Windows; -use bevy_math::Vec2; pub const UI_Z_STEP: f32 = 0.001; diff --git a/crates/bevy_wgpu/src/lib.rs b/crates/bevy_wgpu/src/lib.rs index 0a0b7c3211..087b758a38 100644 --- a/crates/bevy_wgpu/src/lib.rs +++ b/crates/bevy_wgpu/src/lib.rs @@ -10,7 +10,7 @@ pub use wgpu_renderer::*; pub use wgpu_resources::*; use bevy_app::{AppBuilder, AppPlugin}; -use bevy_ecs::{IntoQuerySystem, Resources, IntoThreadLocalSystem, World}; +use bevy_ecs::{IntoQuerySystem, IntoThreadLocalSystem, Resources, World}; use bevy_render::{ render_resource::{free_shared_buffers_system, SharedBuffers}, renderer::RenderResourceContext, diff --git a/crates/bevy_winit/src/lib.rs b/crates/bevy_winit/src/lib.rs index 7f7d505c34..7caf626a6d 100644 --- a/crates/bevy_winit/src/lib.rs +++ b/crates/bevy_winit/src/lib.rs @@ -9,10 +9,10 @@ use bevy_input::{ use bevy_app::{App, AppBuilder, AppExit, AppPlugin, EventReader, Events}; use bevy_ecs::Resources; +use bevy_math::Vec2; use bevy_window::{ CreateWindow, CursorMoved, Window, WindowCloseRequested, WindowCreated, WindowResized, Windows, }; -use bevy_math::Vec2; use winit::{ event, event::{DeviceEvent, WindowEvent}, diff --git a/src/prelude.rs b/src/prelude.rs index 1f666be6d1..3519f338c0 100644 --- a/src/prelude.rs +++ b/src/prelude.rs @@ -5,9 +5,7 @@ pub use crate::{ }, asset::{AddAsset, AssetEvent, AssetServer, Assets, Handle}, audio::{AudioOutput, AudioSource}, - core::{ - time::{Time, Timer}, - }, + core::time::{Time, Timer}, diagnostic::DiagnosticsPlugin, ecs::{ Bundle, Commands, Component, Entity, FromResources, IntoForEachSystem, IntoQuerySystem, @@ -15,7 +13,7 @@ pub use crate::{ World, WorldBuilderSource, }, input::{keyboard::KeyCode, mouse::MouseButton, Input}, - math::{self, Mat3, Mat4, Quat, Vec2, Vec3, Vec4, FaceToward}, + math::{self, FaceToward, Mat3, Mat4, Quat, Vec2, Vec3, Vec4}, pbr::{entity::*, light::Light, material::StandardMaterial}, property::{DynamicProperties, Properties, PropertiesVal, Property, PropertyVal}, render::{