Miscellaneous code-quality improvements. (#5860)

Does what it do.

Co-authored-by: devil-ira <justthecooldude@gmail.com>
This commit is contained in:
ira 2022-09-05 00:30:21 +00:00
parent 7a29c707bf
commit 76ae6f4c6e
11 changed files with 66 additions and 81 deletions

View File

@ -1,4 +1,4 @@
use bevy_ecs::{event::Events, prelude::*}; use bevy_ecs::prelude::*;
// In this example a system sends a custom event with a 50/50 chance during any frame. // In this example a system sends a custom event with a 50/50 chance during any frame.
// If an event was send, it will be printed by the console in a receiving system. // If an event was send, it will be printed by the console in a receiving system.

View File

@ -207,9 +207,8 @@ impl<'w, 's, E: Event> EventReader<'w, 's, E> {
&mut self, &mut self,
) -> impl DoubleEndedIterator<Item = (&E, EventId<E>)> + ExactSizeIterator<Item = (&E, EventId<E>)> ) -> impl DoubleEndedIterator<Item = (&E, EventId<E>)> + ExactSizeIterator<Item = (&E, EventId<E>)>
{ {
self.reader.iter_with_id(&self.events).map(|r @ (_, id)| { self.reader.iter_with_id(&self.events).inspect(|(_, id)| {
trace!("EventReader::iter() -> {}", id); trace!("EventReader::iter() -> {}", id);
r
}) })
} }
@ -313,7 +312,7 @@ impl<'w, 's, E: Event> EventWriter<'w, 's, E> {
self.events.send(event); self.events.send(event);
} }
pub fn send_batch(&mut self, events: impl Iterator<Item = E>) { pub fn send_batch(&mut self, events: impl IntoIterator<Item = E>) {
self.events.extend(events); self.events.extend(events);
} }

View File

@ -615,35 +615,35 @@ impl VertexAttributeValues {
/// mesh, all of the [`VertexAttributeValues`] must have the same length. /// mesh, all of the [`VertexAttributeValues`] must have the same length.
#[allow(clippy::match_same_arms)] #[allow(clippy::match_same_arms)]
pub fn len(&self) -> usize { pub fn len(&self) -> usize {
match *self { match self {
VertexAttributeValues::Float32(ref values) => values.len(), VertexAttributeValues::Float32(values) => values.len(),
VertexAttributeValues::Sint32(ref values) => values.len(), VertexAttributeValues::Sint32(values) => values.len(),
VertexAttributeValues::Uint32(ref values) => values.len(), VertexAttributeValues::Uint32(values) => values.len(),
VertexAttributeValues::Float32x2(ref values) => values.len(), VertexAttributeValues::Float32x2(values) => values.len(),
VertexAttributeValues::Sint32x2(ref values) => values.len(), VertexAttributeValues::Sint32x2(values) => values.len(),
VertexAttributeValues::Uint32x2(ref values) => values.len(), VertexAttributeValues::Uint32x2(values) => values.len(),
VertexAttributeValues::Float32x3(ref values) => values.len(), VertexAttributeValues::Float32x3(values) => values.len(),
VertexAttributeValues::Sint32x3(ref values) => values.len(), VertexAttributeValues::Sint32x3(values) => values.len(),
VertexAttributeValues::Uint32x3(ref values) => values.len(), VertexAttributeValues::Uint32x3(values) => values.len(),
VertexAttributeValues::Float32x4(ref values) => values.len(), VertexAttributeValues::Float32x4(values) => values.len(),
VertexAttributeValues::Sint32x4(ref values) => values.len(), VertexAttributeValues::Sint32x4(values) => values.len(),
VertexAttributeValues::Uint32x4(ref values) => values.len(), VertexAttributeValues::Uint32x4(values) => values.len(),
VertexAttributeValues::Sint16x2(ref values) => values.len(), VertexAttributeValues::Sint16x2(values) => values.len(),
VertexAttributeValues::Snorm16x2(ref values) => values.len(), VertexAttributeValues::Snorm16x2(values) => values.len(),
VertexAttributeValues::Uint16x2(ref values) => values.len(), VertexAttributeValues::Uint16x2(values) => values.len(),
VertexAttributeValues::Unorm16x2(ref values) => values.len(), VertexAttributeValues::Unorm16x2(values) => values.len(),
VertexAttributeValues::Sint16x4(ref values) => values.len(), VertexAttributeValues::Sint16x4(values) => values.len(),
VertexAttributeValues::Snorm16x4(ref values) => values.len(), VertexAttributeValues::Snorm16x4(values) => values.len(),
VertexAttributeValues::Uint16x4(ref values) => values.len(), VertexAttributeValues::Uint16x4(values) => values.len(),
VertexAttributeValues::Unorm16x4(ref values) => values.len(), VertexAttributeValues::Unorm16x4(values) => values.len(),
VertexAttributeValues::Sint8x2(ref values) => values.len(), VertexAttributeValues::Sint8x2(values) => values.len(),
VertexAttributeValues::Snorm8x2(ref values) => values.len(), VertexAttributeValues::Snorm8x2(values) => values.len(),
VertexAttributeValues::Uint8x2(ref values) => values.len(), VertexAttributeValues::Uint8x2(values) => values.len(),
VertexAttributeValues::Unorm8x2(ref values) => values.len(), VertexAttributeValues::Unorm8x2(values) => values.len(),
VertexAttributeValues::Sint8x4(ref values) => values.len(), VertexAttributeValues::Sint8x4(values) => values.len(),
VertexAttributeValues::Snorm8x4(ref values) => values.len(), VertexAttributeValues::Snorm8x4(values) => values.len(),
VertexAttributeValues::Uint8x4(ref values) => values.len(), VertexAttributeValues::Uint8x4(values) => values.len(),
VertexAttributeValues::Unorm8x4(ref values) => values.len(), VertexAttributeValues::Unorm8x4(values) => values.len(),
} }
} }
@ -666,34 +666,34 @@ impl VertexAttributeValues {
#[allow(clippy::match_same_arms)] #[allow(clippy::match_same_arms)]
pub fn get_bytes(&self) -> &[u8] { pub fn get_bytes(&self) -> &[u8] {
match self { match self {
VertexAttributeValues::Float32(values) => cast_slice(&values[..]), VertexAttributeValues::Float32(values) => cast_slice(values),
VertexAttributeValues::Sint32(values) => cast_slice(&values[..]), VertexAttributeValues::Sint32(values) => cast_slice(values),
VertexAttributeValues::Uint32(values) => cast_slice(&values[..]), VertexAttributeValues::Uint32(values) => cast_slice(values),
VertexAttributeValues::Float32x2(values) => cast_slice(&values[..]), VertexAttributeValues::Float32x2(values) => cast_slice(values),
VertexAttributeValues::Sint32x2(values) => cast_slice(&values[..]), VertexAttributeValues::Sint32x2(values) => cast_slice(values),
VertexAttributeValues::Uint32x2(values) => cast_slice(&values[..]), VertexAttributeValues::Uint32x2(values) => cast_slice(values),
VertexAttributeValues::Float32x3(values) => cast_slice(&values[..]), VertexAttributeValues::Float32x3(values) => cast_slice(values),
VertexAttributeValues::Sint32x3(values) => cast_slice(&values[..]), VertexAttributeValues::Sint32x3(values) => cast_slice(values),
VertexAttributeValues::Uint32x3(values) => cast_slice(&values[..]), VertexAttributeValues::Uint32x3(values) => cast_slice(values),
VertexAttributeValues::Float32x4(values) => cast_slice(&values[..]), VertexAttributeValues::Float32x4(values) => cast_slice(values),
VertexAttributeValues::Sint32x4(values) => cast_slice(&values[..]), VertexAttributeValues::Sint32x4(values) => cast_slice(values),
VertexAttributeValues::Uint32x4(values) => cast_slice(&values[..]), VertexAttributeValues::Uint32x4(values) => cast_slice(values),
VertexAttributeValues::Sint16x2(values) => cast_slice(&values[..]), VertexAttributeValues::Sint16x2(values) => cast_slice(values),
VertexAttributeValues::Snorm16x2(values) => cast_slice(&values[..]), VertexAttributeValues::Snorm16x2(values) => cast_slice(values),
VertexAttributeValues::Uint16x2(values) => cast_slice(&values[..]), VertexAttributeValues::Uint16x2(values) => cast_slice(values),
VertexAttributeValues::Unorm16x2(values) => cast_slice(&values[..]), VertexAttributeValues::Unorm16x2(values) => cast_slice(values),
VertexAttributeValues::Sint16x4(values) => cast_slice(&values[..]), VertexAttributeValues::Sint16x4(values) => cast_slice(values),
VertexAttributeValues::Snorm16x4(values) => cast_slice(&values[..]), VertexAttributeValues::Snorm16x4(values) => cast_slice(values),
VertexAttributeValues::Uint16x4(values) => cast_slice(&values[..]), VertexAttributeValues::Uint16x4(values) => cast_slice(values),
VertexAttributeValues::Unorm16x4(values) => cast_slice(&values[..]), VertexAttributeValues::Unorm16x4(values) => cast_slice(values),
VertexAttributeValues::Sint8x2(values) => cast_slice(&values[..]), VertexAttributeValues::Sint8x2(values) => cast_slice(values),
VertexAttributeValues::Snorm8x2(values) => cast_slice(&values[..]), VertexAttributeValues::Snorm8x2(values) => cast_slice(values),
VertexAttributeValues::Uint8x2(values) => cast_slice(&values[..]), VertexAttributeValues::Uint8x2(values) => cast_slice(values),
VertexAttributeValues::Unorm8x2(values) => cast_slice(&values[..]), VertexAttributeValues::Unorm8x2(values) => cast_slice(values),
VertexAttributeValues::Sint8x4(values) => cast_slice(&values[..]), VertexAttributeValues::Sint8x4(values) => cast_slice(values),
VertexAttributeValues::Snorm8x4(values) => cast_slice(&values[..]), VertexAttributeValues::Snorm8x4(values) => cast_slice(values),
VertexAttributeValues::Uint8x4(values) => cast_slice(&values[..]), VertexAttributeValues::Uint8x4(values) => cast_slice(values),
VertexAttributeValues::Unorm8x4(values) => cast_slice(&values[..]), VertexAttributeValues::Unorm8x4(values) => cast_slice(values),
} }
} }
} }

View File

@ -12,10 +12,7 @@
//! //!
//! For more details on the `WorldQuery` derive macro, see the trait documentation. //! For more details on the `WorldQuery` derive macro, see the trait documentation.
use bevy::{ use bevy::{ecs::query::WorldQuery, prelude::*};
ecs::{component::Component, query::WorldQuery},
prelude::*,
};
use std::fmt::Debug; use std::fmt::Debug;
fn main() { fn main() {

View File

@ -1,6 +1,6 @@
//! Shows how to iterate over combinations of query results. //! Shows how to iterate over combinations of query results.
use bevy::{pbr::AmbientLight, prelude::*, render::camera::Camera, time::FixedTimestep}; use bevy::{pbr::AmbientLight, prelude::*, time::FixedTimestep};
use rand::{thread_rng, Rng}; use rand::{thread_rng, Rng};
#[derive(Debug, Hash, PartialEq, Eq, Clone, StageLabel)] #[derive(Debug, Hash, PartialEq, Eq, Clone, StageLabel)]

View File

@ -1,9 +1,6 @@
//! Demonstrates handling a key press/release. //! Demonstrates handling a key press/release.
use bevy::{ use bevy::prelude::*;
input::{keyboard::KeyCode, Input},
prelude::*,
};
fn main() { fn main() {
App::new() App::new()

View File

@ -1,9 +1,6 @@
//! Demonstrates using key modifiers (ctrl, shift). //! Demonstrates using key modifiers (ctrl, shift).
use bevy::{ use bevy::prelude::*;
input::{keyboard::KeyCode, Input},
prelude::*,
};
fn main() { fn main() {
App::new() App::new()

View File

@ -3,7 +3,6 @@
use bevy::{ use bevy::{
input::mouse::{MouseButtonInput, MouseMotion, MouseWheel}, input::mouse::{MouseButtonInput, MouseMotion, MouseWheel},
prelude::*, prelude::*,
window::CursorMoved,
}; };
fn main() { fn main() {

View File

@ -3,7 +3,6 @@
use bevy::{ use bevy::{
core_pipeline::core_3d::Transparent3d, core_pipeline::core_3d::Transparent3d,
ecs::system::{lifetimeless::*, SystemParamItem}, ecs::system::{lifetimeless::*, SystemParamItem},
math::prelude::*,
pbr::{MeshPipeline, MeshPipelineKey, MeshUniform, SetMeshBindGroup, SetMeshViewBindGroup}, pbr::{MeshPipeline, MeshPipelineKey, MeshUniform, SetMeshBindGroup, SetMeshViewBindGroup},
prelude::*, prelude::*,
render::{ render::{
@ -16,7 +15,7 @@ use bevy::{
}, },
render_resource::*, render_resource::*,
renderer::RenderDevice, renderer::RenderDevice,
view::{ComputedVisibility, ExtractedView, Msaa, NoFrustumCulling, Visibility}, view::{ExtractedView, NoFrustumCulling},
RenderApp, RenderStage, RenderApp, RenderStage,
}, },
}; };

View File

@ -9,9 +9,7 @@
use bevy::{ use bevy::{
diagnostic::{FrameTimeDiagnosticsPlugin, LogDiagnosticsPlugin}, diagnostic::{FrameTimeDiagnosticsPlugin, LogDiagnosticsPlugin},
math::Quat,
prelude::*, prelude::*,
render::camera::Camera,
window::PresentMode, window::PresentMode,
}; };

View File

@ -3,10 +3,9 @@
//! This is useful for making desktop applications, or any other program that doesn't need to be //! This is useful for making desktop applications, or any other program that doesn't need to be
//! running the event loop non-stop. //! running the event loop non-stop.
use std::time::Duration;
use bevy::{ use bevy::{
prelude::*, prelude::*,
utils::Duration,
window::{PresentMode, RequestRedraw}, window::{PresentMode, RequestRedraw},
winit::WinitSettings, winit::WinitSettings,
}; };