diff --git a/crates/bevy_app/src/app_builder.rs b/crates/bevy_app/src/app_builder.rs index 0acd946adb..c32f380607 100644 --- a/crates/bevy_app/src/app_builder.rs +++ b/crates/bevy_app/src/app_builder.rs @@ -185,9 +185,9 @@ impl AppBuilder { /// Adds a new [State] with the given `initial` value. /// This inserts a new `State` resource and adds a new "driver" to [CoreStage::Update]. - /// Each stage that uses `State` for system run criteria needs a driver. If you need to use your state in a - /// different stage, consider using [Self::add_state_to_stage] or manually adding [State::get_driver] to additional stages - /// you need it in. + /// Each stage that uses `State` for system run criteria needs a driver. If you need to use + /// your state in a different stage, consider using [Self::add_state_to_stage] or manually + /// adding [State::get_driver] to additional stages you need it in. pub fn add_state(&mut self, initial: T) -> &mut Self where T: Component + Debug + Clone + Eq + Hash, @@ -197,9 +197,9 @@ impl AppBuilder { /// Adds a new [State] with the given `initial` value. /// This inserts a new `State` resource and adds a new "driver" to the given stage. - /// Each stage that uses `State` for system run criteria needs a driver. If you need to use your state in - /// more than one stage, consider manually adding [State::get_driver] to the stages - /// you need it in. + /// Each stage that uses `State` for system run criteria needs a driver. If you need to use + /// your state in more than one stage, consider manually adding [State::get_driver] to the + /// stages you need it in. pub fn add_state_to_stage(&mut self, stage: impl StageLabel, initial: T) -> &mut Self where T: Component + Debug + Clone + Eq + Hash, diff --git a/crates/bevy_ecs/src/component/mod.rs b/crates/bevy_ecs/src/component/mod.rs index 30cb986fdd..e8fba0b62b 100644 --- a/crates/bevy_ecs/src/component/mod.rs +++ b/crates/bevy_ecs/src/component/mod.rs @@ -344,7 +344,8 @@ impl ComponentTicks { } /// Manually sets the change tick. - /// Usually, this is done automatically via the [`DerefMut`](std::ops::DerefMut) implementation on [`Mut`](crate::world::Mut) or [`ResMut`](crate::system::ResMut) etc. + /// Usually, this is done automatically via the [`DerefMut`](std::ops::DerefMut) implementation + /// on [`Mut`](crate::world::Mut) or [`ResMut`](crate::system::ResMut) etc. /// /// # Example /// ```rust,no_run diff --git a/crates/bevy_ecs/src/schedule/stage.rs b/crates/bevy_ecs/src/schedule/stage.rs index 78f27306f9..44e6de9fb3 100644 --- a/crates/bevy_ecs/src/schedule/stage.rs +++ b/crates/bevy_ecs/src/schedule/stage.rs @@ -891,8 +891,7 @@ impl Stage for SystemStage { mod tests { use crate::{ entity::Entity, - query::ChangeTrackers, - query::Changed, + query::{ChangeTrackers, Changed}, schedule::{ BoxedSystemLabel, ExclusiveSystemDescriptorCoercion, ParallelSystemDescriptorCoercion, RunCriteria, RunCriteriaDescriptorCoercion, RunCriteriaPiping, ShouldRun, diff --git a/crates/bevy_ecs/src/schedule/state.rs b/crates/bevy_ecs/src/schedule/state.rs index e7b663db8d..d80fb7970d 100644 --- a/crates/bevy_ecs/src/schedule/state.rs +++ b/crates/bevy_ecs/src/schedule/state.rs @@ -300,7 +300,8 @@ where } /// Schedule a state change that replaces the full stack with the given state. - /// This will fail if there is a scheduled operation, or if the given `state` matches the current state + /// This will fail if there is a scheduled operation, or if the given `state` matches the + /// current state pub fn replace(&mut self, state: T) -> Result<(), StateError> { if self.stack.last().unwrap() == &state { return Err(StateError::AlreadyInState); @@ -314,7 +315,8 @@ where Ok(()) } - /// Same as [Self::replace], but if there is already a next state, it will be overwritten instead of failing + /// Same as [Self::replace], but if there is already a next state, it will be overwritten + /// instead of failing pub fn overwrite_replace(&mut self, state: T) -> Result<(), StateError> { if self.stack.last().unwrap() == &state { return Err(StateError::AlreadyInState); diff --git a/crates/bevy_ecs/src/storage/table.rs b/crates/bevy_ecs/src/storage/table.rs index bccc4c08ed..8a6acabaf8 100644 --- a/crates/bevy_ecs/src/storage/table.rs +++ b/crates/bevy_ecs/src/storage/table.rs @@ -328,8 +328,8 @@ impl Table { let available_space = self.capacity - self.len(); if available_space < amount { let min_capacity = self.len() + amount; - // normally we would check if min_capacity is 0 for the below calculation, but amount > available_space and - // available_space > 0, so min_capacity > 1 + // normally we would check if min_capacity is 0 for the below calculation, but amount > + // available_space and available_space > 0, so min_capacity > 1 let new_capacity = ((min_capacity + self.grow_amount - 1) / self.grow_amount) * self.grow_amount; let reserve_amount = new_capacity - self.len(); diff --git a/crates/bevy_ecs/src/system/commands.rs b/crates/bevy_ecs/src/system/commands.rs index aa31646b56..d7336db107 100644 --- a/crates/bevy_ecs/src/system/commands.rs +++ b/crates/bevy_ecs/src/system/commands.rs @@ -86,8 +86,8 @@ impl<'a> Commands<'a> { /// Creates a new entity with the components contained in `bundle`. /// - /// This returns an [`EntityCommands`] builder, which enables inserting more components and bundles - /// using a "builder pattern". + /// This returns an [`EntityCommands`] builder, which enables inserting more components and + /// bundles using a "builder pattern". /// /// Note that `bundle` is a [`Bundle`], which is a collection of components. [`Bundle`] is /// automatically implemented for tuples of components. You can also create your own bundle @@ -212,9 +212,9 @@ impl<'a, 'b> EntityCommands<'a, 'b> { /// # Warning /// /// It's possible to call this with a bundle, but this is likely not intended and - /// [`Self::insert_bundle`] should be used instead. If `with` is called with a bundle, the bundle - /// itself will be added as a component instead of the bundles' inner components each being - /// added. + /// [`Self::insert_bundle`] should be used instead. If `with` is called with a bundle, the + /// bundle itself will be added as a component instead of the bundles' inner components each + /// being added. /// /// # Example /// diff --git a/crates/bevy_ecs/src/system/into_system.rs b/crates/bevy_ecs/src/system/into_system.rs index 5ec5b707e9..648bb5edd0 100644 --- a/crates/bevy_ecs/src/system/into_system.rs +++ b/crates/bevy_ecs/src/system/into_system.rs @@ -51,7 +51,8 @@ impl SystemState { /// Conversion trait to turn something into a [`System`]. /// -/// Use this to get a system from a function. Also note that every system implements this trait as well. +/// Use this to get a system from a function. Also note that every system implements this trait as +/// well. /// /// # Examples /// @@ -106,9 +107,9 @@ pub struct InputMarker; /// The [`System`] counter part of an ordinary function. /// -/// You get this by calling [`IntoSystem::system`] on a function that only accepts [`SystemParam`]s. -/// The output of the system becomes the functions return type, while the input becomes the functions -/// [`In`] tagged parameter or `()` if no such paramater exists. +/// You get this by calling [`IntoSystem::system`] on a function that only accepts +/// [`SystemParam`]s. The output of the system becomes the functions return type, while the input +/// becomes the functions [`In`] tagged parameter or `()` if no such paramater exists. pub struct FunctionSystem where Param: SystemParam, diff --git a/crates/bevy_ecs/src/system/query.rs b/crates/bevy_ecs/src/system/query.rs index ca0144ec7d..03cfd8f08c 100644 --- a/crates/bevy_ecs/src/system/query.rs +++ b/crates/bevy_ecs/src/system/query.rs @@ -126,7 +126,8 @@ where /// Runs `f` on each query result in parallel using the given task pool. /// - /// This can only be called for read-only queries, see [`Self::par_for_each_mut`] for write-queries. + /// This can only be called for read-only queries, see [`Self::par_for_each_mut`] for + /// write-queries. #[inline] pub fn par_for_each( &self, @@ -270,7 +271,8 @@ where } /// Gets a mutable reference to the [`Entity`]'s [`Component`] of the given type. This will fail - /// if the entity does not have the given component type or the component does not match the query. + /// if the entity does not have the given component type or the component does not match the + /// query. /// /// # Safety /// @@ -352,7 +354,8 @@ where } } - /// Gets the query result if it is only a single result, otherwise returns a [`QuerySingleError`]. + /// Gets the query result if it is only a single result, otherwise returns a + /// [`QuerySingleError`]. pub fn single_mut(&mut self) -> Result<>::Item, QuerySingleError> { let mut query = self.iter_mut(); let first = query.next(); @@ -381,8 +384,8 @@ pub enum QueryComponentError { NoSuchEntity, } -/// An error that occurs when evaluating a [`Query`] as a single expected resulted via [`Query::single`] -/// or [`Query::single_mut`]. +/// An error that occurs when evaluating a [`Query`] as a single expected resulted via +/// [`Query::single`] or [`Query::single_mut`]. #[derive(Debug, Error)] pub enum QuerySingleError { #[error("No entities fit the query {0}")] diff --git a/crates/bevy_ecs/src/system/system.rs b/crates/bevy_ecs/src/system/system.rs index a13967bfa8..12b77135a1 100644 --- a/crates/bevy_ecs/src/system/system.rs +++ b/crates/bevy_ecs/src/system/system.rs @@ -31,7 +31,8 @@ impl SystemId { /// It's possible to specify explicit execution order between specific systems, /// see [SystemDescriptor](crate::schedule::SystemDescriptor). pub trait System: Send + Sync + 'static { - /// The system's input. See [`In`](crate::system::In) for [`FunctionSystem`](crate::system::FunctionSystem)s. + /// The system's input. See [`In`](crate::system::In) for + /// [`FunctionSystem`](crate::system::FunctionSystem)s. type In; /// The system's output. type Out; diff --git a/crates/bevy_input/src/input.rs b/crates/bevy_input/src/input.rs index 927b37b098..1067fdf194 100644 --- a/crates/bevy_input/src/input.rs +++ b/crates/bevy_input/src/input.rs @@ -74,8 +74,8 @@ where self.just_pressed.contains(&input) } - /// Clear the "just pressed" state of `input`. Future calls to [`Input::just_pressed`] for the given - /// input will return false until a new press event occurs. + /// Clear the "just pressed" state of `input`. Future calls to [`Input::just_pressed`] for the + /// given input will return false until a new press event occurs. /// Returns true if `input` is currently "just pressed" pub fn clear_just_pressed(&mut self, input: T) -> bool { self.just_pressed.remove(&input) @@ -86,8 +86,8 @@ where self.just_released.contains(&input) } - /// Clear the "just released" state of `input`. Future calls to [`Input::just_released`] for the given - /// input will return false until a new release event occurs. + /// Clear the "just released" state of `input`. Future calls to [`Input::just_released`] for the + /// given input will return false until a new release event occurs. /// Returns true if `input` is currently "just released" pub fn clear_just_released(&mut self, input: T) -> bool { self.just_released.remove(&input) diff --git a/crates/bevy_pbr/src/material.rs b/crates/bevy_pbr/src/material.rs index 61e6718da7..73c1f80ac6 100644 --- a/crates/bevy_pbr/src/material.rs +++ b/crates/bevy_pbr/src/material.rs @@ -7,20 +7,20 @@ use bevy_render::{color::Color, renderer::RenderResources, shader::ShaderDefs, t #[derive(Debug, RenderResources, ShaderDefs, TypeUuid)] #[uuid = "dace545e-4bc6-4595-a79d-c224fc694975"] pub struct StandardMaterial { - /// Doubles as diffuse albedo for non-metallic, specular for metallic and a mix for everything in between - /// If used together with a base_color_texture, this is factored into the final base color - /// as `base_color * base_color_texture_value` + /// Doubles as diffuse albedo for non-metallic, specular for metallic and a mix for everything + /// in between If used together with a base_color_texture, this is factored into the final + /// base color as `base_color * base_color_texture_value` pub base_color: Color, #[shader_def] pub base_color_texture: Option>, /// Linear perceptual roughness, clamped to [0.089, 1.0] in the shader /// Defaults to minimum of 0.089 - /// If used together with a roughness/metallic texture, this is factored into the final base color - /// as `roughness * roughness_texture_value` + /// If used together with a roughness/metallic texture, this is factored into the final base + /// color as `roughness * roughness_texture_value` pub roughness: f32, /// From [0.0, 1.0], dielectric to pure metallic - /// If used together with a roughness/metallic texture, this is factored into the final base color - /// as `metallic * metallic_texture_value` + /// If used together with a roughness/metallic texture, this is factored into the final base + /// color as `metallic * metallic_texture_value` pub metallic: f32, /// Specular intensity for non-metals on a linear scale of [0.0, 1.0] /// defaults to 0.5 which is mapped to 4% reflectance in the shader @@ -51,8 +51,9 @@ impl Default for StandardMaterial { base_color_texture: None, // This is the minimum the roughness is clamped to in shader code // See https://google.github.io/filament/Filament.html#materialsystem/parameterization/ - // It's the minimum floating point value that won't be rounded down to 0 in the calculations used. - // Although technically for 32-bit floats, 0.045 could be used. + // It's the minimum floating point value that won't be rounded down to 0 in the + // calculations used. Although technically for 32-bit floats, 0.045 could be + // used. roughness: 0.089, // Few materials are purely dielectric or metallic // This is just a default for mostly-dielectric diff --git a/crates/bevy_reflect/src/reflect.rs b/crates/bevy_reflect/src/reflect.rs index 2d03764a6f..9271997479 100644 --- a/crates/bevy_reflect/src/reflect.rs +++ b/crates/bevy_reflect/src/reflect.rs @@ -24,8 +24,9 @@ pub enum ReflectMut<'a> { /// A reflected rust type. /// /// # Safety -/// Implementors _must_ ensure that [Reflect::any] and [Reflect::any_mut] both return the `self` value passed in -/// If this is not done, [Reflect::downcast] will be UB (and also just logically broken). +/// Implementors _must_ ensure that [Reflect::any] and [Reflect::any_mut] both return the `self` +/// value passed in If this is not done, [Reflect::downcast] will be UB (and also just logically +/// broken). pub unsafe trait Reflect: Any + Send + Sync { fn type_name(&self) -> &str; fn any(&self) -> &dyn Any; diff --git a/crates/bevy_render/src/color.rs b/crates/bevy_render/src/color.rs index 80d968dc6f..bb8b1f80c4 100644 --- a/crates/bevy_render/src/color.rs +++ b/crates/bevy_render/src/color.rs @@ -25,7 +25,8 @@ pub enum Color { /// Alpha component. [0.0, 1.0] alpha: f32, }, - /// RGBA color in the Linear sRGB colorspace (often colloquially referred to as "linear", "RGB", or "linear RGB"). + /// RGBA color in the Linear sRGB colorspace (often colloquially referred to as "linear", + /// "RGB", or "linear RGB"). RgbaLinear { /// Red component. [0.0, 1.0] red: f32, diff --git a/crates/bevy_render/src/mesh/mesh.rs b/crates/bevy_render/src/mesh/mesh.rs index 0b2bea277f..ddb7275312 100644 --- a/crates/bevy_render/src/mesh/mesh.rs +++ b/crates/bevy_render/src/mesh/mesh.rs @@ -222,8 +222,8 @@ impl From<&Indices> for IndexFormat { #[uuid = "8ecbac0f-f545-4473-ad43-e1f4243af51e"] pub struct Mesh { primitive_topology: PrimitiveTopology, - /// `std::collections::BTreeMap` with all defined vertex attributes (Positions, Normals, ...) for this - /// mesh. Attribute name maps to attribute values. + /// `std::collections::BTreeMap` with all defined vertex attributes (Positions, Normals, ...) + /// for this mesh. Attribute name maps to attribute values. /// Uses a BTreeMap because, unlike HashMap, it has a defined iteration order, /// which allows easy stable VertexBuffers (i.e. same buffer order) attributes: BTreeMap, VertexAttributeValues>, diff --git a/crates/bevy_render/src/render_graph/nodes/pass_node.rs b/crates/bevy_render/src/render_graph/nodes/pass_node.rs index 5258f9fa3e..4f211a535c 100644 --- a/crates/bevy_render/src/render_graph/nodes/pass_node.rs +++ b/crates/bevy_render/src/render_graph/nodes/pass_node.rs @@ -167,7 +167,8 @@ where } for render_command in draw.render_commands.iter() { commands.push(render_command.clone()); - // whenever a new pipeline is set, ensure the relevant camera bind groups are set + // whenever a new pipeline is set, ensure the relevant camera bind groups + // are set if let RenderCommand::SetPipeline { pipeline } = render_command { let bind_groups = pipeline_camera_commands .entry(pipeline.clone_weak()) diff --git a/crates/bevy_text/src/text2d.rs b/crates/bevy_text/src/text2d.rs index 907d60a081..c5634cdfa8 100644 --- a/crates/bevy_text/src/text2d.rs +++ b/crates/bevy_text/src/text2d.rs @@ -53,9 +53,9 @@ impl Default for Text2dBundle { } } -/// System for drawing text in a 2D scene via a 2D `OrthographicCameraBundle`. Included in the default -/// `TextPlugin`. Position is determined by the `Transform`'s translation, though scale and rotation -/// are ignored. +/// System for drawing text in a 2D scene via a 2D `OrthographicCameraBundle`. Included in the +/// default `TextPlugin`. Position is determined by the `Transform`'s translation, though scale and +/// rotation are ignored. pub fn draw_text2d_system( mut context: DrawContext, msaa: Res, diff --git a/examples/2d/many_sprites.rs b/examples/2d/many_sprites.rs index bc9f3e7c89..a63fa9a693 100644 --- a/examples/2d/many_sprites.rs +++ b/examples/2d/many_sprites.rs @@ -12,8 +12,8 @@ const CAMERA_SPEED: f32 = 1000.0; pub struct PrintTimer(Timer); pub struct Position(Transform); -///This example is for performance testing purposes. -///See https://github.com/bevyengine/bevy/pull/1492 +/// This example is for performance testing purposes. +/// See https://github.com/bevyengine/bevy/pull/1492 fn main() { App::build() .add_plugin(LogDiagnosticsPlugin::default()) diff --git a/examples/3d/render_to_texture.rs b/examples/3d/render_to_texture.rs index 64f8c3ab8d..bfc61a324e 100644 --- a/examples/3d/render_to_texture.rs +++ b/examples/3d/render_to_texture.rs @@ -169,7 +169,8 @@ fn setup( let mut first_pass_camera = PerspectiveCameraBundle { camera: Camera { name: Some(FIRST_PASS_CAMERA.to_string()), - window: WindowId::new(), // otherwise it will use main window size / aspect for calculation of projection matrix + window: WindowId::new(), /* otherwise it will use main window size / aspect for + * calculation of projection matrix */ ..Default::default() }, transform: Transform::from_translation(Vec3::new(0.0, 0.0, 15.0)) diff --git a/examples/shader/animate_shader.rs b/examples/shader/animate_shader.rs index 790f8bc89f..bcc8a478b4 100644 --- a/examples/shader/animate_shader.rs +++ b/examples/shader/animate_shader.rs @@ -84,7 +84,8 @@ fn setup( fragment: Some(shaders.add(Shader::from_glsl(ShaderStage::Fragment, FRAGMENT_SHADER))), })); - // Add a `RenderResourcesNode` to our `RenderGraph`. This will bind `TimeComponent` to our shader. + // Add a `RenderResourcesNode` to our `RenderGraph`. This will bind `TimeComponent` to our + // shader. render_graph.add_system_node( "time_uniform", RenderResourcesNode::::new(true), @@ -115,9 +116,9 @@ fn setup( }); } -/// In this system we query for the `TimeComponent` and global `Time` resource, and set `time.seconds_since_startup()` -/// as the `value` of the `TimeComponent`. This value will be accessed by the fragment shader and used -/// to animate the shader. +/// In this system we query for the `TimeComponent` and global `Time` resource, and set +/// `time.seconds_since_startup()` as the `value` of the `TimeComponent`. This value will be +/// accessed by the fragment shader and used to animate the shader. fn animate_shader(time: Res