Skip to content

Commit

Permalink
Cargo fmt with unstable features (#1903)
Browse files Browse the repository at this point in the history
Fresh version of #1670 off the latest main.

Mostly fixing documentation wrapping.
  • Loading branch information
alice-i-cecile committed Apr 21, 2021
1 parent 30c6ca6 commit e4e3259
Show file tree
Hide file tree
Showing 20 changed files with 75 additions and 63 deletions.
12 changes: 6 additions & 6 deletions crates/bevy_app/src/app_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -185,9 +185,9 @@ impl AppBuilder {

/// Adds a new [State] with the given `initial` value.
/// This inserts a new `State<T>` resource and adds a new "driver" to [CoreStage::Update].
/// Each stage that uses `State<T>` 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<T>` 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<T>(&mut self, initial: T) -> &mut Self
where
T: Component + Debug + Clone + Eq + Hash,
Expand All @@ -197,9 +197,9 @@ impl AppBuilder {

/// Adds a new [State] with the given `initial` value.
/// This inserts a new `State<T>` resource and adds a new "driver" to the given stage.
/// Each stage that uses `State<T>` 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<T>` 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<T>(&mut self, stage: impl StageLabel, initial: T) -> &mut Self
where
T: Component + Debug + Clone + Eq + Hash,
Expand Down
3 changes: 2 additions & 1 deletion crates/bevy_ecs/src/component/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 1 addition & 2 deletions crates/bevy_ecs/src/schedule/stage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
6 changes: 4 additions & 2 deletions crates/bevy_ecs/src/schedule/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions crates/bevy_ecs/src/storage/table.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
10 changes: 5 additions & 5 deletions crates/bevy_ecs/src/system/commands.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
///
Expand Down
9 changes: 5 additions & 4 deletions crates/bevy_ecs/src/system/into_system.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
///
Expand Down Expand Up @@ -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<In, Out, Param, Marker, F>
where
Param: SystemParam,
Expand Down
13 changes: 8 additions & 5 deletions crates/bevy_ecs/src/system/query.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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
///
Expand Down Expand Up @@ -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<<Q::Fetch as Fetch<'_>>::Item, QuerySingleError> {
let mut query = self.iter_mut();
let first = query.next();
Expand Down Expand Up @@ -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}")]
Expand Down
3 changes: 2 additions & 1 deletion crates/bevy_ecs/src/system/system.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
8 changes: 4 additions & 4 deletions crates/bevy_input/src/input.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
Expand Down
19 changes: 10 additions & 9 deletions crates/bevy_pbr/src/material.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<Handle<Texture>>,
/// 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
Expand Down Expand Up @@ -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
Expand Down
5 changes: 3 additions & 2 deletions crates/bevy_reflect/src/reflect.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
3 changes: 2 additions & 1 deletion crates/bevy_render/src/color.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
4 changes: 2 additions & 2 deletions crates/bevy_render/src/mesh/mesh.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<Cow<'static, str>, VertexAttributeValues>,
Expand Down
3 changes: 2 additions & 1 deletion crates/bevy_render/src/render_graph/nodes/pass_node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand Down
6 changes: 3 additions & 3 deletions crates/bevy_text/src/text2d.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<Msaa>,
Expand Down
4 changes: 2 additions & 2 deletions examples/2d/many_sprites.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand Down
3 changes: 2 additions & 1 deletion examples/3d/render_to_texture.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
9 changes: 5 additions & 4 deletions examples/shader/animate_shader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::<TimeUniform>::new(true),
Expand Down Expand Up @@ -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<Time>, mut query: Query<&mut TimeUniform>) {
let mut time_uniform = query.single_mut().unwrap();
time_uniform.value = time.seconds_since_startup() as f32;
Expand Down
11 changes: 5 additions & 6 deletions rustfmt.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,8 @@ newline_style = "Unix"

# The following lines may be uncommented on nightly Rust.
# Once these features have stabilized, they should be added to the always-enabled options above.
#unstable_features = true
#imports_granularity = "Crate"
#reorder_impl_items = true
#wrap_comments = true
#comment_width = 100
#normalize_comments = true
# unstable_features = true
# imports_granularity = "Crate"
# wrap_comments = true
# comment_width = 100
# normalize_comments = true

0 comments on commit e4e3259

Please sign in to comment.