diff --git a/Cargo.toml b/Cargo.toml index 1c95c166e0..120fd6d679 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -45,6 +45,9 @@ ptr_as_ptr = "warn" ptr_cast_constness = "warn" ref_as_ptr = "warn" +# see: https://github.com/bevyengine/bevy/pull/15375#issuecomment-2366966219 +too_long_first_doc_paragraph = "allow" + [workspace.lints.rust] missing_docs = "warn" unexpected_cfgs = { level = "warn", check-cfg = ['cfg(docsrs_dep)'] } diff --git a/crates/bevy_a11y/src/lib.rs b/crates/bevy_a11y/src/lib.rs index 66b5d333be..bb5cbc71cd 100644 --- a/crates/bevy_a11y/src/lib.rs +++ b/crates/bevy_a11y/src/lib.rs @@ -21,8 +21,7 @@ use bevy_ecs::{ schedule::SystemSet, system::Resource, }; -use bevy_reflect::std_traits::ReflectDefault; -use bevy_reflect::Reflect; +use bevy_reflect::{std_traits::ReflectDefault, Reflect}; /// Wrapper struct for [`accesskit::ActionRequest`]. Required to allow it to be used as an `Event`. #[derive(Event, Deref, DerefMut)] diff --git a/crates/bevy_animation/src/graph.rs b/crates/bevy_animation/src/graph.rs index 6f04ca794f..916cfa26f6 100644 --- a/crates/bevy_animation/src/graph.rs +++ b/crates/bevy_animation/src/graph.rs @@ -1,7 +1,9 @@ //! The animation graph, which allows animations to be blended together. -use std::io::{self, Write}; -use std::ops::{Index, IndexMut}; +use std::{ + io::{self, Write}, + ops::{Index, IndexMut}, +}; use bevy_asset::{io::Reader, Asset, AssetId, AssetLoader, AssetPath, Handle, LoadContext}; use bevy_reflect::{Reflect, ReflectSerialize}; diff --git a/crates/bevy_animation/src/keyframes.rs b/crates/bevy_animation/src/keyframes.rs index f2694930c0..bed12e1908 100644 --- a/crates/bevy_animation/src/keyframes.rs +++ b/crates/bevy_animation/src/keyframes.rs @@ -1,20 +1,27 @@ //! Keyframes of animation clips. -use std::any::TypeId; -use std::fmt::{self, Debug, Formatter}; +use std::{ + any::TypeId, + fmt::{self, Debug, Formatter}, +}; use bevy_asset::Handle; use bevy_derive::{Deref, DerefMut}; -use bevy_ecs::component::Component; -use bevy_ecs::world::{EntityMutExcept, Mut}; +use bevy_ecs::{ + component::Component, + world::{EntityMutExcept, Mut}, +}; use bevy_math::{Quat, Vec3}; use bevy_reflect::{FromReflect, GetTypeRegistration, Reflect, TypePath, Typed}; use bevy_render::mesh::morph::MorphWeights; use bevy_transform::prelude::Transform; -use crate::graph::AnimationGraph; -use crate::prelude::{Animatable, GetKeyframe}; -use crate::{animatable, AnimationEvaluationError, AnimationPlayer, Interpolation}; +use crate::{ + animatable, + graph::AnimationGraph, + prelude::{Animatable, GetKeyframe}, + AnimationEvaluationError, AnimationPlayer, Interpolation, +}; /// A value on a component that Bevy can animate. /// diff --git a/crates/bevy_animation/src/lib.rs b/crates/bevy_animation/src/lib.rs index 837accc6fa..e6d8b3294a 100755 --- a/crates/bevy_animation/src/lib.rs +++ b/crates/bevy_animation/src/lib.rs @@ -13,34 +13,33 @@ pub mod keyframes; pub mod transition; mod util; -use std::any::{Any, TypeId}; -use std::cell::RefCell; -use std::collections::BTreeMap; -use std::fmt::Debug; -use std::hash::{Hash, Hasher}; -use std::iter; +use std::{ + any::{Any, TypeId}, + cell::RefCell, + collections::BTreeMap, + fmt::Debug, + hash::{Hash, Hasher}, + iter, +}; use bevy_app::{App, Plugin, PostUpdate}; use bevy_asset::{Asset, AssetApp, Assets, Handle}; use bevy_core::Name; -use bevy_ecs::entity::MapEntities; -use bevy_ecs::prelude::*; -use bevy_ecs::reflect::ReflectMapEntities; -use bevy_ecs::world::EntityMutExcept; +use bevy_ecs::{ + entity::MapEntities, prelude::*, reflect::ReflectMapEntities, world::EntityMutExcept, +}; use bevy_math::FloatExt; -use bevy_reflect::utility::NonGenericTypeInfoCell; -use bevy_reflect::{prelude::ReflectDefault, Reflect}; use bevy_reflect::{ - ApplyError, DynamicStruct, FieldIter, FromReflect, FromType, GetTypeRegistration, NamedField, - PartialReflect, ReflectFromPtr, ReflectKind, ReflectMut, ReflectOwned, ReflectRef, Struct, - StructInfo, TypeInfo, TypePath, TypeRegistration, Typed, + prelude::ReflectDefault, utility::NonGenericTypeInfoCell, ApplyError, DynamicStruct, FieldIter, + FromReflect, FromType, GetTypeRegistration, NamedField, PartialReflect, Reflect, + ReflectFromPtr, ReflectKind, ReflectMut, ReflectOwned, ReflectRef, Struct, StructInfo, + TypeInfo, TypePath, TypeRegistration, Typed, }; use bevy_time::Time; -use bevy_transform::prelude::Transform; -use bevy_transform::TransformSystem; +use bevy_transform::{prelude::Transform, TransformSystem}; use bevy_ui::UiSystem; -use bevy_utils::hashbrown::HashMap; use bevy_utils::{ + hashbrown::HashMap, tracing::{trace, warn}, NoOpHash, }; diff --git a/crates/bevy_app/src/app.rs b/crates/bevy_app/src/app.rs index b0d223662b..6cd6d181a6 100644 --- a/crates/bevy_app/src/app.rs +++ b/crates/bevy_app/src/app.rs @@ -15,11 +15,9 @@ use bevy_utils::tracing::info_span; use bevy_utils::{tracing::debug, HashMap}; use std::{ fmt::Debug, - process::{ExitCode, Termination}, -}; -use std::{ num::NonZero, panic::{catch_unwind, resume_unwind, AssertUnwindSafe}, + process::{ExitCode, Termination}, }; use thiserror::Error; diff --git a/crates/bevy_app/src/main_schedule.rs b/crates/bevy_app/src/main_schedule.rs index 3ee0a07a74..f2b5494437 100644 --- a/crates/bevy_app/src/main_schedule.rs +++ b/crates/bevy_app/src/main_schedule.rs @@ -78,6 +78,7 @@ pub struct First; pub struct PreUpdate; /// Runs the [`FixedMain`] schedule in a loop according until all relevant elapsed time has been "consumed". +/// /// If you need to order your variable timestep systems /// before or after the fixed update logic, use the [`RunFixedMainLoopSystem`] system set. /// diff --git a/crates/bevy_app/src/panic_handler.rs b/crates/bevy_app/src/panic_handler.rs index 94bb1c206c..56d66da728 100644 --- a/crates/bevy_app/src/panic_handler.rs +++ b/crates/bevy_app/src/panic_handler.rs @@ -6,8 +6,7 @@ //! For more fine-tuned control over panic behavior, disable the [`PanicHandlerPlugin`] or //! `DefaultPlugins` during app initialization. -use crate::App; -use crate::Plugin; +use crate::{App, Plugin}; /// Adds sensible panic handlers to Apps. This plugin is part of the `DefaultPlugins`. Adding /// this plugin will setup a panic hook appropriate to your target platform: diff --git a/crates/bevy_app/src/plugin_group.rs b/crates/bevy_app/src/plugin_group.rs index 28c90ff5ef..be6f2c229a 100644 --- a/crates/bevy_app/src/plugin_group.rs +++ b/crates/bevy_app/src/plugin_group.rs @@ -1,5 +1,8 @@ use crate::{App, AppError, Plugin}; -use bevy_utils::{tracing::debug, tracing::warn, TypeIdMap}; +use bevy_utils::{ + tracing::{debug, warn}, + TypeIdMap, +}; use std::any::TypeId; /// A macro for generating a well-documented [`PluginGroup`] from a list of [`Plugin`] paths. @@ -185,6 +188,7 @@ fn type_id_of_val(_: &T) -> TypeId { } /// Facilitates the creation and configuration of a [`PluginGroup`]. +/// /// Provides a build ordering to ensure that [`Plugin`]s which produce/require a [`Resource`](bevy_ecs::system::Resource) /// are built before/after dependent/depending [`Plugin`]s. [`Plugin`]s inside the group /// can be disabled, enabled or reordered. diff --git a/crates/bevy_asset/src/assets.rs b/crates/bevy_asset/src/assets.rs index 5a0dfcf824..c9cab3af64 100644 --- a/crates/bevy_asset/src/assets.rs +++ b/crates/bevy_asset/src/assets.rs @@ -1,5 +1,7 @@ -use crate::{self as bevy_asset}; -use crate::{Asset, AssetEvent, AssetHandleProvider, AssetId, AssetServer, Handle, UntypedHandle}; +use crate::{ + self as bevy_asset, Asset, AssetEvent, AssetHandleProvider, AssetId, AssetServer, Handle, + UntypedHandle, +}; use bevy_ecs::{ prelude::EventWriter, system::{Res, ResMut, Resource}, diff --git a/crates/bevy_asset/src/id.rs b/crates/bevy_asset/src/id.rs index c4b48a06d6..f1a28d7e02 100644 --- a/crates/bevy_asset/src/id.rs +++ b/crates/bevy_asset/src/id.rs @@ -303,6 +303,7 @@ impl PartialOrd for UntypedAssetId { } /// An asset id without static or dynamic types associated with it. +/// /// This exist to support efficient type erased id drop tracking. We /// could use [`UntypedAssetId`] for this, but the [`TypeId`] is unnecessary. /// diff --git a/crates/bevy_asset/src/io/embedded/embedded_watcher.rs b/crates/bevy_asset/src/io/embedded/embedded_watcher.rs index 485593599c..9a432977a7 100644 --- a/crates/bevy_asset/src/io/embedded/embedded_watcher.rs +++ b/crates/bevy_asset/src/io/embedded/embedded_watcher.rs @@ -3,8 +3,7 @@ use crate::io::{ memory::Dir, AssetSourceEvent, AssetWatcher, }; -use bevy_utils::tracing::warn; -use bevy_utils::{Duration, HashMap}; +use bevy_utils::{tracing::warn, Duration, HashMap}; use notify_debouncer_full::{notify::RecommendedWatcher, Debouncer, FileIdMap}; use parking_lot::RwLock; use std::{ diff --git a/crates/bevy_asset/src/io/file/file_watcher.rs b/crates/bevy_asset/src/io/file/file_watcher.rs index 12793b738b..1da55fae97 100644 --- a/crates/bevy_asset/src/io/file/file_watcher.rs +++ b/crates/bevy_asset/src/io/file/file_watcher.rs @@ -1,7 +1,8 @@ -use crate::io::{AssetSourceEvent, AssetWatcher}; -use crate::path::normalize_path; -use bevy_utils::tracing::error; -use bevy_utils::Duration; +use crate::{ + io::{AssetSourceEvent, AssetWatcher}, + path::normalize_path, +}; +use bevy_utils::{tracing::error, Duration}; use crossbeam_channel::Sender; use notify_debouncer_full::{ new_debouncer, diff --git a/crates/bevy_asset/src/io/memory.rs b/crates/bevy_asset/src/io/memory.rs index a3707e9b13..082b64b8dc 100644 --- a/crates/bevy_asset/src/io/memory.rs +++ b/crates/bevy_asset/src/io/memory.rs @@ -3,8 +3,8 @@ use bevy_utils::HashMap; use futures_io::{AsyncRead, AsyncSeek}; use futures_lite::{ready, Stream}; use parking_lot::RwLock; -use std::io::SeekFrom; use std::{ + io::SeekFrom, path::{Path, PathBuf}, pin::Pin, sync::Arc, diff --git a/crates/bevy_asset/src/io/processor_gated.rs b/crates/bevy_asset/src/io/processor_gated.rs index a77c787797..4e079e4088 100644 --- a/crates/bevy_asset/src/io/processor_gated.rs +++ b/crates/bevy_asset/src/io/processor_gated.rs @@ -6,9 +6,7 @@ use crate::{ use async_lock::RwLockReadGuardArc; use bevy_utils::tracing::trace; use futures_io::{AsyncRead, AsyncSeek}; -use std::io::SeekFrom; -use std::task::Poll; -use std::{path::Path, pin::Pin, sync::Arc}; +use std::{io::SeekFrom, path::Path, pin::Pin, sync::Arc, task::Poll}; use super::ErasedAssetReader; diff --git a/crates/bevy_asset/src/io/source.rs b/crates/bevy_asset/src/io/source.rs index 0a53caa23c..650537c96f 100644 --- a/crates/bevy_asset/src/io/source.rs +++ b/crates/bevy_asset/src/io/source.rs @@ -4,8 +4,10 @@ use crate::{ }; use atomicow::CowArc; use bevy_ecs::system::Resource; -use bevy_utils::tracing::{error, warn}; -use bevy_utils::{Duration, HashMap}; +use bevy_utils::{ + tracing::{error, warn}, + Duration, HashMap, +}; use std::{fmt::Display, hash::Hash, sync::Arc}; use thiserror::Error; diff --git a/crates/bevy_asset/src/lib.rs b/crates/bevy_asset/src/lib.rs index 6220af7c01..9e5c24df84 100644 --- a/crates/bevy_asset/src/lib.rs +++ b/crates/bevy_asset/src/lib.rs @@ -617,9 +617,9 @@ mod tests { }; use bevy_app::{App, Update}; use bevy_core::TaskPoolPlugin; - use bevy_ecs::prelude::*; use bevy_ecs::{ event::EventCursor, + prelude::*, schedule::{LogLevel, ScheduleBuildSettings}, }; use bevy_log::LogPlugin; diff --git a/crates/bevy_asset/src/loader.rs b/crates/bevy_asset/src/loader.rs index 401c7db609..7e2e7cc56c 100644 --- a/crates/bevy_asset/src/loader.rs +++ b/crates/bevy_asset/src/loader.rs @@ -310,6 +310,7 @@ pub enum DeserializeMetaError { } /// A context that provides access to assets in [`AssetLoader`]s, tracks dependencies, and collects asset load state. +/// /// Any asset state accessed by [`LoadContext`] will be tracked and stored for use in dependency events and asset preprocessing. pub struct LoadContext<'a> { pub(crate) asset_server: &'a AssetServer, diff --git a/crates/bevy_asset/src/loader_builders.rs b/crates/bevy_asset/src/loader_builders.rs index 27609a411e..8bebe9f0bd 100644 --- a/crates/bevy_asset/src/loader_builders.rs +++ b/crates/bevy_asset/src/loader_builders.rs @@ -7,8 +7,7 @@ use crate::{ Asset, AssetLoadError, AssetPath, ErasedAssetLoader, ErasedLoadedAsset, Handle, LoadContext, LoadDirectError, LoadedAsset, LoadedUntypedAsset, }; -use std::any::TypeId; -use std::sync::Arc; +use std::{any::TypeId, sync::Arc}; // Utility type for handling the sources of reader references enum ReaderRef<'a> { diff --git a/crates/bevy_asset/src/meta.rs b/crates/bevy_asset/src/meta.rs index b0a7a9cab0..7b65eb8f48 100644 --- a/crates/bevy_asset/src/meta.rs +++ b/crates/bevy_asset/src/meta.rs @@ -1,5 +1,7 @@ -use crate::{self as bevy_asset, DeserializeMetaError, VisitAssetDependencies}; -use crate::{loader::AssetLoader, processor::Process, Asset, AssetPath}; +use crate::{ + self as bevy_asset, loader::AssetLoader, processor::Process, Asset, AssetPath, + DeserializeMetaError, VisitAssetDependencies, +}; use bevy_utils::tracing::error; use downcast_rs::{impl_downcast, Downcast}; use ron::ser::PrettyConfig; diff --git a/crates/bevy_asset/src/processor/log.rs b/crates/bevy_asset/src/processor/log.rs index 64207295e7..2649b815d8 100644 --- a/crates/bevy_asset/src/processor/log.rs +++ b/crates/bevy_asset/src/processor/log.rs @@ -1,7 +1,6 @@ use crate::AssetPath; use async_fs::File; -use bevy_utils::tracing::error; -use bevy_utils::HashSet; +use bevy_utils::{tracing::error, HashSet}; use futures_lite::{AsyncReadExt, AsyncWriteExt}; use std::path::PathBuf; use thiserror::Error; @@ -15,6 +14,7 @@ pub(crate) enum LogEntry { } /// A "write ahead" logger that helps ensure asset importing is transactional. +/// /// Prior to processing an asset, we write to the log to indicate it has started /// After processing an asset, we write to the log to indicate it has finished. /// On startup, the log can be read to determine if any transactions were incomplete. diff --git a/crates/bevy_asset/src/processor/mod.rs b/crates/bevy_asset/src/processor/mod.rs index 7188f9dab4..c93ee65dc2 100644 --- a/crates/bevy_asset/src/processor/mod.rs +++ b/crates/bevy_asset/src/processor/mod.rs @@ -58,13 +58,15 @@ use crate::{ }; use bevy_ecs::prelude::*; use bevy_tasks::IoTaskPool; -use bevy_utils::tracing::{debug, error, trace, warn}; +use bevy_utils::{ + tracing::{debug, error, trace, warn}, + HashMap, HashSet, +}; #[cfg(feature = "trace")] use bevy_utils::{ tracing::{info_span, instrument::Instrument}, ConditionalSendFuture, }; -use bevy_utils::{HashMap, HashSet}; use futures_io::ErrorKind; use futures_lite::{AsyncReadExt, AsyncWriteExt, StreamExt}; use parking_lot::RwLock; diff --git a/crates/bevy_asset/src/processor/process.rs b/crates/bevy_asset/src/processor/process.rs index 92a13f21ff..c77ac3848a 100644 --- a/crates/bevy_asset/src/processor/process.rs +++ b/crates/bevy_asset/src/processor/process.rs @@ -1,14 +1,12 @@ -use crate::io::SliceReader; -use crate::transformer::IdentityAssetTransformer; use crate::{ io::{ AssetReaderError, AssetWriterError, MissingAssetWriterError, - MissingProcessedAssetReaderError, MissingProcessedAssetWriterError, Writer, + MissingProcessedAssetReaderError, MissingProcessedAssetWriterError, SliceReader, Writer, }, meta::{AssetAction, AssetMeta, AssetMetaDyn, ProcessDependencyInfo, ProcessedInfo, Settings}, processor::AssetProcessor, saver::{AssetSaver, SavedAsset}, - transformer::{AssetTransformer, TransformedAsset}, + transformer::{AssetTransformer, IdentityAssetTransformer, TransformedAsset}, AssetLoadError, AssetLoader, AssetPath, DeserializeMetaError, ErasedLoadedAsset, MissingAssetLoaderForExtensionError, MissingAssetLoaderForTypeNameError, }; diff --git a/crates/bevy_asset/src/saver.rs b/crates/bevy_asset/src/saver.rs index 115a880377..0234c9210b 100644 --- a/crates/bevy_asset/src/saver.rs +++ b/crates/bevy_asset/src/saver.rs @@ -1,6 +1,7 @@ -use crate::transformer::TransformedAsset; -use crate::{io::Writer, meta::Settings, Asset, ErasedLoadedAsset}; -use crate::{AssetLoader, Handle, LabeledAsset, UntypedHandle}; +use crate::{ + io::Writer, meta::Settings, transformer::TransformedAsset, Asset, AssetLoader, + ErasedLoadedAsset, Handle, LabeledAsset, UntypedHandle, +}; use atomicow::CowArc; use bevy_utils::{BoxedFuture, ConditionalSendFuture, HashMap}; use serde::{Deserialize, Serialize}; diff --git a/crates/bevy_asset/src/server/info.rs b/crates/bevy_asset/src/server/info.rs index b8e6840c1f..ace0df54c3 100644 --- a/crates/bevy_asset/src/server/info.rs +++ b/crates/bevy_asset/src/server/info.rs @@ -6,8 +6,7 @@ use crate::{ }; use bevy_ecs::world::World; use bevy_tasks::Task; -use bevy_utils::tracing::warn; -use bevy_utils::{Entry, HashMap, HashSet, TypeIdMap}; +use bevy_utils::{tracing::warn, Entry, HashMap, HashSet, TypeIdMap}; use crossbeam_channel::Sender; use std::{ any::TypeId, diff --git a/crates/bevy_asset/src/server/loaders.rs b/crates/bevy_asset/src/server/loaders.rs index b0ecba7ae3..307918b75b 100644 --- a/crates/bevy_asset/src/server/loaders.rs +++ b/crates/bevy_asset/src/server/loaders.rs @@ -4,13 +4,15 @@ use crate::{ }; use async_broadcast::RecvError; use bevy_tasks::IoTaskPool; -use bevy_utils::tracing::{error, warn}; +use bevy_utils::{ + tracing::{error, warn}, + HashMap, TypeIdMap, +}; #[cfg(feature = "trace")] use bevy_utils::{ tracing::{info_span, instrument::Instrument}, ConditionalSendFuture, }; -use bevy_utils::{HashMap, TypeIdMap}; use std::{any::TypeId, sync::Arc}; use thiserror::Error; diff --git a/crates/bevy_asset/src/server/mod.rs b/crates/bevy_asset/src/server/mod.rs index ad28b585be..90f618f865 100644 --- a/crates/bevy_asset/src/server/mod.rs +++ b/crates/bevy_asset/src/server/mod.rs @@ -20,16 +20,22 @@ use crate::{ use atomicow::CowArc; use bevy_ecs::prelude::*; use bevy_tasks::IoTaskPool; -use bevy_utils::tracing::{error, info}; -use bevy_utils::HashSet; +use bevy_utils::{ + tracing::{error, info}, + HashSet, +}; use crossbeam_channel::{Receiver, Sender}; use futures_lite::{FutureExt, StreamExt}; use info::*; use loaders::*; use parking_lot::RwLock; -use std::{any::Any, path::PathBuf}; -use std::{any::TypeId, path::Path, sync::Arc}; -use std::{future::Future, panic::AssertUnwindSafe}; +use std::{ + any::{Any, TypeId}, + future::Future, + panic::AssertUnwindSafe, + path::{Path, PathBuf}, + sync::Arc, +}; use thiserror::Error; /// Loads and tracks the state of [`Asset`] values from a configured [`AssetReader`](crate::io::AssetReader). This can be used to kick off new asset loads and diff --git a/crates/bevy_audio/src/audio.rs b/crates/bevy_audio/src/audio.rs index ec50201a16..d6af1906de 100644 --- a/crates/bevy_audio/src/audio.rs +++ b/crates/bevy_audio/src/audio.rs @@ -44,6 +44,7 @@ pub enum PlaybackMode { } /// Initial settings to be used when audio starts playing. +/// /// If you would like to control the audio while it is playing, query for the /// [`AudioSink`][crate::AudioSink] or [`SpatialAudioSink`][crate::SpatialAudioSink] /// components. Changes to this component will *not* be applied to already-playing audio. diff --git a/crates/bevy_audio/src/audio_source.rs b/crates/bevy_audio/src/audio_source.rs index 64a481b328..ae1e42606d 100644 --- a/crates/bevy_audio/src/audio_source.rs +++ b/crates/bevy_audio/src/audio_source.rs @@ -73,6 +73,7 @@ impl AssetLoader for AudioLoader { } /// A type implementing this trait can be converted to a [`rodio::Source`] type. +/// /// It must be [`Send`] and [`Sync`] in order to be registered. /// Types that implement this trait usually contain raw sound data that can be converted into an iterator of samples. /// This trait is implemented for [`AudioSource`]. diff --git a/crates/bevy_audio/src/lib.rs b/crates/bevy_audio/src/lib.rs index 65d7b4e6bc..0683dfa858 100644 --- a/crates/bevy_audio/src/lib.rs +++ b/crates/bevy_audio/src/lib.rs @@ -48,9 +48,7 @@ pub use audio::*; pub use audio_source::*; pub use pitch::*; -pub use rodio::cpal::Sample as CpalSample; -pub use rodio::source::Source; -pub use rodio::Sample; +pub use rodio::{cpal::Sample as CpalSample, source::Source, Sample}; pub use sinks::*; use bevy_app::prelude::*; diff --git a/crates/bevy_audio/src/pitch.rs b/crates/bevy_audio/src/pitch.rs index 3cc913b66f..442a758f08 100644 --- a/crates/bevy_audio/src/pitch.rs +++ b/crates/bevy_audio/src/pitch.rs @@ -1,7 +1,10 @@ use crate::{AudioSourceBundle, Decodable}; use bevy_asset::Asset; use bevy_reflect::TypePath; -use rodio::{source::SineWave, source::TakeDuration, Source}; +use rodio::{ + source::{SineWave, TakeDuration}, + Source, +}; /// A source of sine wave sound #[derive(Asset, Debug, Clone, TypePath)] diff --git a/crates/bevy_color/src/color_gradient.rs b/crates/bevy_color/src/color_gradient.rs index 60920d6ca3..bb6457e6fd 100644 --- a/crates/bevy_color/src/color_gradient.rs +++ b/crates/bevy_color/src/color_gradient.rs @@ -66,8 +66,7 @@ where #[cfg(test)] mod tests { use super::*; - use crate::palettes::basic; - use crate::Srgba; + use crate::{palettes::basic, Srgba}; #[test] fn test_color_curve() { diff --git a/crates/bevy_color/src/color_range.rs b/crates/bevy_color/src/color_range.rs index 72260b27f4..1661923355 100644 --- a/crates/bevy_color/src/color_range.rs +++ b/crates/bevy_color/src/color_range.rs @@ -22,8 +22,7 @@ impl ColorRange for Range { #[cfg(test)] mod tests { use super::*; - use crate::palettes::basic; - use crate::{LinearRgba, Srgba}; + use crate::{palettes::basic, LinearRgba, Srgba}; #[test] fn test_color_range() { diff --git a/crates/bevy_color/src/lib.rs b/crates/bevy_color/src/lib.rs index 344a159695..d9ff34ae91 100644 --- a/crates/bevy_color/src/lib.rs +++ b/crates/bevy_color/src/lib.rs @@ -57,7 +57,6 @@ //! a form of chromaticity, while `y` defines an illuminance level. //! //! See also the [Wikipedia article on color spaces](https://en.wikipedia.org/wiki/Color_space). -//! #![doc = include_str!("../docs/conversion.md")] //!
#![doc = include_str!("../docs/diagrams/model_graph.svg")] @@ -115,18 +114,10 @@ mod xyza; /// /// This includes the most common types in this crate, re-exported for your convenience. pub mod prelude { - pub use crate::color::*; - pub use crate::color_ops::*; - pub use crate::hsla::*; - pub use crate::hsva::*; - pub use crate::hwba::*; - pub use crate::laba::*; - pub use crate::lcha::*; - pub use crate::linear_rgba::*; - pub use crate::oklaba::*; - pub use crate::oklcha::*; - pub use crate::srgba::*; - pub use crate::xyza::*; + pub use crate::{ + color::*, color_ops::*, hsla::*, hsva::*, hwba::*, laba::*, lcha::*, linear_rgba::*, + oklaba::*, oklcha::*, srgba::*, xyza::*, + }; } pub use color::*; diff --git a/crates/bevy_color/src/palettes/tailwind.rs b/crates/bevy_color/src/palettes/tailwind.rs index 31eb9d42e0..d91cd41ca9 100644 --- a/crates/bevy_color/src/palettes/tailwind.rs +++ b/crates/bevy_color/src/palettes/tailwind.rs @@ -3,29 +3,27 @@ //! //! Generated from Tailwind 3.4.1. -/* -MIT License - -Copyright (c) Tailwind Labs, Inc. - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. -*/ +// MIT License +// +// Copyright (c) Tailwind Labs, Inc. +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. use crate::Srgba; diff --git a/crates/bevy_color/src/srgba.rs b/crates/bevy_color/src/srgba.rs index b235749a64..fac9fd18dd 100644 --- a/crates/bevy_color/src/srgba.rs +++ b/crates/bevy_color/src/srgba.rs @@ -1,7 +1,6 @@ -use crate::color_difference::EuclideanDistance; use crate::{ - impl_componentwise_vector_space, Alpha, ColorToComponents, ColorToPacked, Gray, LinearRgba, - Luminance, Mix, StandardColor, Xyza, + color_difference::EuclideanDistance, impl_componentwise_vector_space, Alpha, ColorToComponents, + ColorToPacked, Gray, LinearRgba, Luminance, Mix, StandardColor, Xyza, }; use bevy_math::{ops, Vec3, Vec4}; #[cfg(feature = "bevy_reflect")] @@ -185,7 +184,6 @@ impl Srgba { /// * `b` - Blue channel. [0, 255] /// /// See also [`Srgba::new`], [`Srgba::rgba_u8`], [`Srgba::hex`]. - /// pub fn rgb_u8(r: u8, g: u8, b: u8) -> Self { Self::from_u8_array_no_alpha([r, g, b]) } @@ -202,7 +200,6 @@ impl Srgba { /// * `a` - Alpha channel. [0, 255] /// /// See also [`Srgba::new`], [`Srgba::rgb_u8`], [`Srgba::hex`]. - /// pub fn rgba_u8(r: u8, g: u8, b: u8, a: u8) -> Self { Self::from_u8_array([r, g, b, a]) } diff --git a/crates/bevy_core/src/name.rs b/crates/bevy_core/src/name.rs index 9f858cf96e..9985f6d1e6 100644 --- a/crates/bevy_core/src/name.rs +++ b/crates/bevy_core/src/name.rs @@ -1,7 +1,6 @@ -use bevy_ecs::query::QueryData; #[cfg(feature = "bevy_reflect")] use bevy_ecs::reflect::ReflectComponent; -use bevy_ecs::{component::Component, entity::Entity}; +use bevy_ecs::{component::Component, entity::Entity, query::QueryData}; #[cfg(feature = "bevy_reflect")] use bevy_reflect::std_traits::ReflectDefault; @@ -141,7 +140,7 @@ impl<'a> std::fmt::Display for NameOrEntityItem<'a> { } } -/* Conversions from strings */ +// Conversions from strings impl From<&str> for Name { #[inline(always)] @@ -156,7 +155,7 @@ impl From for Name { } } -/* Conversions to strings */ +// Conversions to strings impl AsRef for Name { #[inline(always)] diff --git a/crates/bevy_core/src/serde.rs b/crates/bevy_core/src/serde.rs index fc4d81b4bd..b3e3b87098 100644 --- a/crates/bevy_core/src/serde.rs +++ b/crates/bevy_core/src/serde.rs @@ -8,8 +8,7 @@ use serde::{ Deserialize, Deserializer, Serialize, Serializer, }; -use super::name::Name; -use super::FrameCount; +use super::{name::Name, FrameCount}; impl Serialize for Name { fn serialize(&self, serializer: S) -> Result { diff --git a/crates/bevy_core_pipeline/src/auto_exposure/buffers.rs b/crates/bevy_core_pipeline/src/auto_exposure/buffers.rs index 76698d14c4..836c18b3a7 100644 --- a/crates/bevy_core_pipeline/src/auto_exposure/buffers.rs +++ b/crates/bevy_core_pipeline/src/auto_exposure/buffers.rs @@ -6,8 +6,7 @@ use bevy_render::{ }; use bevy_utils::{Entry, HashMap}; -use super::pipeline::AutoExposureUniform; -use super::AutoExposure; +use super::{pipeline::AutoExposureUniform, AutoExposure}; #[derive(Resource, Default)] pub(super) struct AutoExposureBuffers { diff --git a/crates/bevy_core_pipeline/src/auto_exposure/mod.rs b/crates/bevy_core_pipeline/src/auto_exposure/mod.rs index dccd63bff0..59f314d12e 100644 --- a/crates/bevy_core_pipeline/src/auto_exposure/mod.rs +++ b/crates/bevy_core_pipeline/src/auto_exposure/mod.rs @@ -1,17 +1,15 @@ use bevy_app::prelude::*; use bevy_asset::{load_internal_asset, AssetApp, Assets, Handle}; use bevy_ecs::prelude::*; -use bevy_render::extract_component::ExtractComponentPlugin; -use bevy_render::render_asset::RenderAssetPlugin; -use bevy_render::render_resource::Shader; -use bevy_render::ExtractSchedule; use bevy_render::{ + extract_component::ExtractComponentPlugin, + render_asset::RenderAssetPlugin, render_graph::RenderGraphApp, render_resource::{ - Buffer, BufferDescriptor, BufferUsages, PipelineCache, SpecializedComputePipelines, + Buffer, BufferDescriptor, BufferUsages, PipelineCache, Shader, SpecializedComputePipelines, }, renderer::RenderDevice, - Render, RenderApp, RenderSet, + ExtractSchedule, Render, RenderApp, RenderSet, }; mod buffers; @@ -29,8 +27,10 @@ use pipeline::{ #[allow(deprecated)] pub use settings::{AutoExposure, AutoExposureSettings}; -use crate::auto_exposure::compensation_curve::GpuAutoExposureCompensationCurve; -use crate::core_3d::graph::{Core3d, Node3d}; +use crate::{ + auto_exposure::compensation_curve::GpuAutoExposureCompensationCurve, + core_3d::graph::{Core3d, Node3d}, +}; /// Plugin for the auto exposure feature. /// diff --git a/crates/bevy_core_pipeline/src/auto_exposure/settings.rs b/crates/bevy_core_pipeline/src/auto_exposure/settings.rs index 388a67fb79..14c7b551bc 100644 --- a/crates/bevy_core_pipeline/src/auto_exposure/settings.rs +++ b/crates/bevy_core_pipeline/src/auto_exposure/settings.rs @@ -3,8 +3,7 @@ use std::ops::RangeInclusive; use super::compensation_curve::AutoExposureCompensationCurve; use bevy_asset::Handle; use bevy_ecs::{prelude::Component, reflect::ReflectComponent}; -use bevy_reflect::std_traits::ReflectDefault; -use bevy_reflect::Reflect; +use bevy_reflect::{std_traits::ReflectDefault, Reflect}; use bevy_render::{extract_component::ExtractComponent, texture::Image}; use bevy_utils::default; @@ -23,7 +22,6 @@ use bevy_utils::default; /// # Usage Notes /// /// **Auto Exposure requires compute shaders and is not compatible with WebGL2.** -/// #[derive(Component, Clone, Reflect, ExtractComponent)] #[reflect(Component, Default)] pub struct AutoExposure { diff --git a/crates/bevy_core_pipeline/src/contrast_adaptive_sharpening/mod.rs b/crates/bevy_core_pipeline/src/contrast_adaptive_sharpening/mod.rs index 5afde16797..71c9cc2bb2 100644 --- a/crates/bevy_core_pipeline/src/contrast_adaptive_sharpening/mod.rs +++ b/crates/bevy_core_pipeline/src/contrast_adaptive_sharpening/mod.rs @@ -6,8 +6,7 @@ use crate::{ use bevy_app::prelude::*; use bevy_asset::{load_internal_asset, Handle}; use bevy_ecs::{prelude::*, query::QueryItem}; -use bevy_reflect::std_traits::ReflectDefault; -use bevy_reflect::Reflect; +use bevy_reflect::{std_traits::ReflectDefault, Reflect}; use bevy_render::{ extract_component::{ExtractComponent, ExtractComponentPlugin, UniformComponentPlugin}, prelude::Camera, diff --git a/crates/bevy_core_pipeline/src/core_2d/camera_2d.rs b/crates/bevy_core_pipeline/src/core_2d/camera_2d.rs index b2181bdddc..682c15cd03 100644 --- a/crates/bevy_core_pipeline/src/core_2d/camera_2d.rs +++ b/crates/bevy_core_pipeline/src/core_2d/camera_2d.rs @@ -1,15 +1,16 @@ -use crate::core_2d::graph::Core2d; -use crate::tonemapping::{DebandDither, Tonemapping}; +use crate::{ + core_2d::graph::Core2d, + tonemapping::{DebandDither, Tonemapping}, +}; use bevy_ecs::prelude::*; -use bevy_reflect::std_traits::ReflectDefault; -use bevy_reflect::Reflect; -use bevy_render::prelude::Msaa; +use bevy_reflect::{std_traits::ReflectDefault, Reflect}; use bevy_render::{ camera::{ Camera, CameraMainTextureUsages, CameraProjection, CameraRenderGraph, OrthographicProjection, }, extract_component::ExtractComponent, + prelude::Msaa, primitives::Frustum, view::VisibleEntities, }; diff --git a/crates/bevy_core_pipeline/src/core_3d/camera_3d.rs b/crates/bevy_core_pipeline/src/core_3d/camera_3d.rs index c2f703a784..ed748c52bc 100644 --- a/crates/bevy_core_pipeline/src/core_3d/camera_3d.rs +++ b/crates/bevy_core_pipeline/src/core_3d/camera_3d.rs @@ -3,15 +3,13 @@ use crate::{ tonemapping::{DebandDither, Tonemapping}, }; use bevy_ecs::prelude::*; -use bevy_reflect::std_traits::ReflectDefault; -use bevy_reflect::{Reflect, ReflectDeserialize, ReflectSerialize}; -use bevy_render::view::Msaa; +use bevy_reflect::{std_traits::ReflectDefault, Reflect, ReflectDeserialize, ReflectSerialize}; use bevy_render::{ camera::{Camera, CameraMainTextureUsages, CameraRenderGraph, Exposure, Projection}, extract_component::ExtractComponent, primitives::Frustum, render_resource::{LoadOp, TextureUsages}, - view::{ColorGrading, VisibleEntities}, + view::{ColorGrading, Msaa, VisibleEntities}, }; use bevy_transform::prelude::{GlobalTransform, Transform}; use serde::{Deserialize, Serialize}; diff --git a/crates/bevy_core_pipeline/src/deferred/node.rs b/crates/bevy_core_pipeline/src/deferred/node.rs index 44895aaeb8..5aa89a8e94 100644 --- a/crates/bevy_core_pipeline/src/deferred/node.rs +++ b/crates/bevy_core_pipeline/src/deferred/node.rs @@ -1,13 +1,11 @@ -use bevy_ecs::prelude::*; -use bevy_ecs::query::QueryItem; +use bevy_ecs::{prelude::*, query::QueryItem}; use bevy_render::render_graph::ViewNode; -use bevy_render::render_phase::{TrackedRenderPass, ViewBinnedRenderPhases}; -use bevy_render::render_resource::{CommandEncoderDescriptor, StoreOp}; use bevy_render::{ camera::ExtractedCamera, render_graph::{NodeRunError, RenderGraphContext}, - render_resource::RenderPassDescriptor, + render_phase::{TrackedRenderPass, ViewBinnedRenderPhases}, + render_resource::{CommandEncoderDescriptor, RenderPassDescriptor, StoreOp}, renderer::RenderContext, view::ViewDepthTexture, }; diff --git a/crates/bevy_core_pipeline/src/fxaa/mod.rs b/crates/bevy_core_pipeline/src/fxaa/mod.rs index 85fe16bd48..a448444baf 100644 --- a/crates/bevy_core_pipeline/src/fxaa/mod.rs +++ b/crates/bevy_core_pipeline/src/fxaa/mod.rs @@ -10,8 +10,7 @@ use bevy_reflect::{std_traits::ReflectDefault, Reflect}; use bevy_render::{ extract_component::{ExtractComponent, ExtractComponentPlugin}, prelude::Camera, - render_graph::RenderGraphApp, - render_graph::ViewNodeRunner, + render_graph::{RenderGraphApp, ViewNodeRunner}, render_resource::{ binding_types::{sampler, texture_2d}, *, diff --git a/crates/bevy_core_pipeline/src/fxaa/node.rs b/crates/bevy_core_pipeline/src/fxaa/node.rs index 857a3015c1..a58f21d9a7 100644 --- a/crates/bevy_core_pipeline/src/fxaa/node.rs +++ b/crates/bevy_core_pipeline/src/fxaa/node.rs @@ -1,8 +1,7 @@ use std::sync::Mutex; use crate::fxaa::{CameraFxaaPipeline, Fxaa, FxaaPipeline}; -use bevy_ecs::prelude::*; -use bevy_ecs::query::QueryItem; +use bevy_ecs::{prelude::*, query::QueryItem}; use bevy_render::{ render_graph::{NodeRunError, RenderGraphContext, ViewNode}, render_resource::{ diff --git a/crates/bevy_core_pipeline/src/msaa_writeback.rs b/crates/bevy_core_pipeline/src/msaa_writeback.rs index 01f579a0e1..f9c543aeff 100644 --- a/crates/bevy_core_pipeline/src/msaa_writeback.rs +++ b/crates/bevy_core_pipeline/src/msaa_writeback.rs @@ -5,17 +5,15 @@ use crate::{ }; use bevy_app::{App, Plugin}; use bevy_color::LinearRgba; -use bevy_ecs::prelude::*; -use bevy_ecs::query::QueryItem; -use bevy_render::render_graph::{ViewNode, ViewNodeRunner}; +use bevy_ecs::{prelude::*, query::QueryItem}; use bevy_render::{ camera::ExtractedCamera, - render_graph::{NodeRunError, RenderGraphApp, RenderGraphContext}, + render_graph::{NodeRunError, RenderGraphApp, RenderGraphContext, ViewNode, ViewNodeRunner}, + render_resource::*, renderer::RenderContext, view::{Msaa, ViewTarget}, - Render, RenderSet, + Render, RenderApp, RenderSet, }; -use bevy_render::{render_resource::*, RenderApp}; /// This enables "msaa writeback" support for the `core_2d` and `core_3d` pipelines, which can be enabled on cameras /// using [`bevy_render::camera::Camera::msaa_writeback`]. See the docs on that field for more information. diff --git a/crates/bevy_core_pipeline/src/prepass/mod.rs b/crates/bevy_core_pipeline/src/prepass/mod.rs index bebb2a180f..3f408e544f 100644 --- a/crates/bevy_core_pipeline/src/prepass/mod.rs +++ b/crates/bevy_core_pipeline/src/prepass/mod.rs @@ -32,8 +32,7 @@ use std::ops::Range; use bevy_asset::UntypedAssetId; use bevy_ecs::prelude::*; use bevy_math::Mat4; -use bevy_reflect::std_traits::ReflectDefault; -use bevy_reflect::Reflect; +use bevy_reflect::{std_traits::ReflectDefault, Reflect}; use bevy_render::{ render_phase::{ BinnedPhaseItem, CachedRenderPipelinePhaseItem, DrawFunctionId, PhaseItem, diff --git a/crates/bevy_core_pipeline/src/prepass/node.rs b/crates/bevy_core_pipeline/src/prepass/node.rs index d362c36f6c..17f5dfb2cf 100644 --- a/crates/bevy_core_pipeline/src/prepass/node.rs +++ b/crates/bevy_core_pipeline/src/prepass/node.rs @@ -1,5 +1,4 @@ -use bevy_ecs::prelude::*; -use bevy_ecs::query::QueryItem; +use bevy_ecs::{prelude::*, query::QueryItem}; use bevy_render::{ camera::ExtractedCamera, diagnostic::RecordDiagnostics, diff --git a/crates/bevy_core_pipeline/src/taa/mod.rs b/crates/bevy_core_pipeline/src/taa/mod.rs index 635b0a7dbe..56dcd6a69b 100644 --- a/crates/bevy_core_pipeline/src/taa/mod.rs +++ b/crates/bevy_core_pipeline/src/taa/mod.rs @@ -15,8 +15,7 @@ use bevy_ecs::{ world::{FromWorld, World}, }; use bevy_math::vec2; -use bevy_reflect::std_traits::ReflectDefault; -use bevy_reflect::Reflect; +use bevy_reflect::{std_traits::ReflectDefault, Reflect}; use bevy_render::{ camera::{ExtractedCamera, MipBias, TemporalJitter}, prelude::{Camera, Projection}, diff --git a/crates/bevy_core_pipeline/src/tonemapping/mod.rs b/crates/bevy_core_pipeline/src/tonemapping/mod.rs index 353690d165..7614b50153 100644 --- a/crates/bevy_core_pipeline/src/tonemapping/mod.rs +++ b/crates/bevy_core_pipeline/src/tonemapping/mod.rs @@ -2,19 +2,21 @@ use crate::fullscreen_vertex_shader::fullscreen_shader_vertex_state; use bevy_app::prelude::*; use bevy_asset::{load_internal_asset, Assets, Handle}; use bevy_ecs::prelude::*; -use bevy_reflect::std_traits::ReflectDefault; -use bevy_reflect::Reflect; -use bevy_render::extract_component::{ExtractComponent, ExtractComponentPlugin}; -use bevy_render::extract_resource::{ExtractResource, ExtractResourcePlugin}; -use bevy_render::render_asset::{RenderAssetUsages, RenderAssets}; -use bevy_render::render_resource::binding_types::{ - sampler, texture_2d, texture_3d, uniform_buffer, +use bevy_reflect::{std_traits::ReflectDefault, Reflect}; +use bevy_render::{ + camera::Camera, + extract_component::{ExtractComponent, ExtractComponentPlugin}, + extract_resource::{ExtractResource, ExtractResourcePlugin}, + render_asset::{RenderAssetUsages, RenderAssets}, + render_resource::{ + binding_types::{sampler, texture_2d, texture_3d, uniform_buffer}, + *, + }, + renderer::RenderDevice, + texture::{CompressedImageFormats, FallbackImage, GpuImage, Image, ImageSampler, ImageType}, + view::{ExtractedView, ViewTarget, ViewUniform}, + Render, RenderApp, RenderSet, }; -use bevy_render::renderer::RenderDevice; -use bevy_render::texture::{CompressedImageFormats, GpuImage, Image, ImageSampler, ImageType}; -use bevy_render::view::{ExtractedView, ViewTarget, ViewUniform}; -use bevy_render::{camera::Camera, texture::FallbackImage}; -use bevy_render::{render_resource::*, Render, RenderApp, RenderSet}; #[cfg(not(feature = "tonemapping_luts"))] use bevy_utils::tracing::error; use bitflags::bitflags; diff --git a/crates/bevy_core_pipeline/src/upscaling/mod.rs b/crates/bevy_core_pipeline/src/upscaling/mod.rs index 1f99580dbe..42f6744bfb 100644 --- a/crates/bevy_core_pipeline/src/upscaling/mod.rs +++ b/crates/bevy_core_pipeline/src/upscaling/mod.rs @@ -1,9 +1,12 @@ use crate::blit::{BlitPipeline, BlitPipelineKey}; use bevy_app::prelude::*; use bevy_ecs::prelude::*; -use bevy_render::camera::{CameraOutputMode, ExtractedCamera}; -use bevy_render::view::ViewTarget; -use bevy_render::{render_resource::*, Render, RenderApp, RenderSet}; +use bevy_render::{ + camera::{CameraOutputMode, ExtractedCamera}, + render_resource::*, + view::ViewTarget, + Render, RenderApp, RenderSet, +}; use bevy_utils::HashSet; mod node; diff --git a/crates/bevy_core_pipeline/src/upscaling/node.rs b/crates/bevy_core_pipeline/src/upscaling/node.rs index e3b1aa3109..ece71c1947 100644 --- a/crates/bevy_core_pipeline/src/upscaling/node.rs +++ b/crates/bevy_core_pipeline/src/upscaling/node.rs @@ -1,8 +1,7 @@ use crate::{blit::BlitPipeline, upscaling::ViewUpscalingPipeline}; use bevy_ecs::{prelude::*, query::QueryItem}; -use bevy_render::camera::{ClearColor, ClearColorConfig}; use bevy_render::{ - camera::{CameraOutputMode, ExtractedCamera}, + camera::{CameraOutputMode, ClearColor, ClearColorConfig, ExtractedCamera}, render_graph::{NodeRunError, RenderGraphContext, ViewNode}, render_resource::{ BindGroup, BindGroupEntries, PipelineCache, RenderPassDescriptor, TextureViewId, diff --git a/crates/bevy_diagnostic/src/diagnostic.rs b/crates/bevy_diagnostic/src/diagnostic.rs index b45ee593cf..5cd0956f94 100644 --- a/crates/bevy_diagnostic/src/diagnostic.rs +++ b/crates/bevy_diagnostic/src/diagnostic.rs @@ -1,5 +1,8 @@ -use std::hash::{Hash, Hasher}; -use std::{borrow::Cow, collections::VecDeque}; +use std::{ + borrow::Cow, + collections::VecDeque, + hash::{Hash, Hasher}, +}; use bevy_app::{App, SubApp}; use bevy_ecs::system::{Deferred, Res, Resource, SystemBuffer, SystemParam}; diff --git a/crates/bevy_diagnostic/src/log_diagnostics_plugin.rs b/crates/bevy_diagnostic/src/log_diagnostics_plugin.rs index 2f007edcaa..d6e7a2e0b6 100644 --- a/crates/bevy_diagnostic/src/log_diagnostics_plugin.rs +++ b/crates/bevy_diagnostic/src/log_diagnostics_plugin.rs @@ -2,8 +2,10 @@ use super::{Diagnostic, DiagnosticPath, DiagnosticsStore}; use bevy_app::prelude::*; use bevy_ecs::prelude::*; use bevy_time::{Real, Time, Timer, TimerMode}; -use bevy_utils::tracing::{debug, info}; -use bevy_utils::Duration; +use bevy_utils::{ + tracing::{debug, info}, + Duration, +}; /// An App Plugin that logs diagnostics to the console. /// diff --git a/crates/bevy_ecs/src/batching.rs b/crates/bevy_ecs/src/batching.rs index 5143dfb73e..192305c551 100644 --- a/crates/bevy_ecs/src/batching.rs +++ b/crates/bevy_ecs/src/batching.rs @@ -90,7 +90,6 @@ impl BatchingStrategy { /// # Panics /// /// Panics if `thread_count` is 0. - /// #[inline] pub fn calc_batch_size(&self, max_items: impl FnOnce() -> usize, thread_count: usize) -> usize { if self.batch_size_limits.is_empty() { diff --git a/crates/bevy_ecs/src/bundle.rs b/crates/bevy_ecs/src/bundle.rs index 607e14145a..dab5ec6caa 100644 --- a/crates/bevy_ecs/src/bundle.rs +++ b/crates/bevy_ecs/src/bundle.rs @@ -1446,9 +1446,7 @@ fn initialize_dynamic_bundle( #[cfg(test)] mod tests { use crate as bevy_ecs; - use crate::component::ComponentId; - use crate::prelude::*; - use crate::world::DeferredWorld; + use crate::{component::ComponentId, prelude::*, world::DeferredWorld}; #[derive(Component)] struct A; diff --git a/crates/bevy_ecs/src/change_detection.rs b/crates/bevy_ecs/src/change_detection.rs index 247825c285..2dcaedfaee 100644 --- a/crates/bevy_ecs/src/change_detection.rs +++ b/crates/bevy_ecs/src/change_detection.rs @@ -8,10 +8,12 @@ use crate::{ #[cfg(feature = "track_change_detection")] use bevy_ptr::ThinSlicePtr; use bevy_ptr::{Ptr, UnsafeCellDeref}; -use std::mem; -use std::ops::{Deref, DerefMut}; #[cfg(feature = "track_change_detection")] use std::{cell::UnsafeCell, panic::Location}; +use std::{ + mem, + ops::{Deref, DerefMut}, +}; /// The (arbitrarily chosen) minimum number of world tick increments between `check_tick` scans. /// @@ -102,7 +104,6 @@ pub trait DetectChanges { /// resource.0 = 42; // triggers change detection via [`DerefMut`] /// } /// ``` -/// pub trait DetectChangesMut: DetectChanges { /// The type contained within this smart pointer /// diff --git a/crates/bevy_ecs/src/component.rs b/crates/bevy_ecs/src/component.rs index 910bd9fc10..107617002b 100644 --- a/crates/bevy_ecs/src/component.rs +++ b/crates/bevy_ecs/src/component.rs @@ -21,11 +21,12 @@ use std::{ alloc::Layout, any::{Any, TypeId}, borrow::Cow, + cell::UnsafeCell, + fmt::Debug, marker::PhantomData, mem::needs_drop, sync::Arc, }; -use std::{cell::UnsafeCell, fmt::Debug}; /// A data type that can be used to store data for an [entity]. /// @@ -266,7 +267,6 @@ use std::{cell::UnsafeCell, fmt::Debug}; /// fn my_on_insert_hook(world: DeferredWorld, _: T1, _: T2) { /// // ... /// } -/// /// ``` /// /// # Implementing the trait for foreign types diff --git a/crates/bevy_ecs/src/entity/map_entities.rs b/crates/bevy_ecs/src/entity/map_entities.rs index 8283e55e95..96045d3597 100644 --- a/crates/bevy_ecs/src/entity/map_entities.rs +++ b/crates/bevy_ecs/src/entity/map_entities.rs @@ -221,9 +221,8 @@ impl<'m> SceneEntityMapper<'m> { #[cfg(test)] mod tests { - use crate::entity::DynEntityMapper; use crate::{ - entity::{Entity, EntityHashMap, EntityMapper, SceneEntityMapper}, + entity::{DynEntityMapper, Entity, EntityHashMap, EntityMapper, SceneEntityMapper}, world::World, }; use bevy_utils::assert_object_safe; diff --git a/crates/bevy_ecs/src/event/collections.rs b/crates/bevy_ecs/src/event/collections.rs index ea203bdc46..f9e813096c 100644 --- a/crates/bevy_ecs/src/event/collections.rs +++ b/crates/bevy_ecs/src/event/collections.rs @@ -8,8 +8,10 @@ use bevy_ecs::{ #[cfg(feature = "bevy_reflect")] use bevy_reflect::{std_traits::ReflectDefault, Reflect}; use bevy_utils::detailed_trace; -use std::marker::PhantomData; -use std::ops::{Deref, DerefMut}; +use std::{ + marker::PhantomData, + ops::{Deref, DerefMut}, +}; /// An event collection that represents the events that occurred within the last two /// [`Events::update`] calls. diff --git a/crates/bevy_ecs/src/event/mutator.rs b/crates/bevy_ecs/src/event/mutator.rs index faa350138f..ee77f9961a 100644 --- a/crates/bevy_ecs/src/event/mutator.rs +++ b/crates/bevy_ecs/src/event/mutator.rs @@ -96,7 +96,6 @@ impl<'w, 's, E: Event> EventMutator<'w, 's, E> { /// // all events were processed /// assert_eq!(counter.into_inner(), 4950); /// ``` - /// #[cfg(feature = "multi_threaded")] pub fn par_read(&mut self) -> EventMutParIter<'_, E> { self.reader.par_read_mut(&mut self.events) diff --git a/crates/bevy_ecs/src/event/reader.rs b/crates/bevy_ecs/src/event/reader.rs index f816978a64..1611fa6ba5 100644 --- a/crates/bevy_ecs/src/event/reader.rs +++ b/crates/bevy_ecs/src/event/reader.rs @@ -68,7 +68,6 @@ impl<'w, 's, E: Event> EventReader<'w, 's, E> { /// // all events were processed /// assert_eq!(counter.into_inner(), 4950); /// ``` - /// #[cfg(feature = "multi_threaded")] pub fn par_read(&mut self) -> EventParIter<'_, E> { self.reader.par_read(&self.events) diff --git a/crates/bevy_ecs/src/identifier/mod.rs b/crates/bevy_ecs/src/identifier/mod.rs index 54bb29218b..6018a9f85f 100644 --- a/crates/bevy_ecs/src/identifier/mod.rs +++ b/crates/bevy_ecs/src/identifier/mod.rs @@ -14,6 +14,7 @@ pub(crate) mod kinds; pub(crate) mod masks; /// A unified identifier for all entity and similar IDs. +/// /// Has the same size as a `u64` integer, but the layout is split between a 32-bit low /// segment, a 31-bit high segment, and the significant bit reserved as type flags to denote /// entity kinds. diff --git a/crates/bevy_ecs/src/intern.rs b/crates/bevy_ecs/src/intern.rs index 54ea4e3207..84ade58024 100644 --- a/crates/bevy_ecs/src/intern.rs +++ b/crates/bevy_ecs/src/intern.rs @@ -24,7 +24,6 @@ use bevy_utils::HashSet; /// Two interned values are only guaranteed to compare equal if they were interned using /// the same [`Interner`] instance. // NOTE: This type must NEVER implement Borrow since it does not obey that trait's invariants. -/// /// ``` /// # use bevy_ecs::intern::*; /// #[derive(PartialEq, Eq, Hash, Debug)] diff --git a/crates/bevy_ecs/src/lib.rs b/crates/bevy_ecs/src/lib.rs index aa24c15a3c..c257231ccd 100644 --- a/crates/bevy_ecs/src/lib.rs +++ b/crates/bevy_ecs/src/lib.rs @@ -77,23 +77,22 @@ pub mod prelude { #[cfg(test)] mod tests { use crate as bevy_ecs; - use crate::prelude::Or; - use crate::world::EntityMut; use crate::{ bundle::Bundle, change_detection::Ref, component::{Component, ComponentId}, entity::Entity, + prelude::Or, query::{Added, Changed, FilteredAccess, QueryFilter, With, Without}, system::Resource, - world::{EntityRef, Mut, World}, + world::{EntityMut, EntityRef, Mut, World}, }; use bevy_tasks::{ComputeTaskPool, TaskPool}; use bevy_utils::HashSet; - use std::num::NonZero; use std::{ any::TypeId, marker::PhantomData, + num::NonZero, sync::{ atomic::{AtomicUsize, Ordering}, Arc, Mutex, diff --git a/crates/bevy_ecs/src/observer/mod.rs b/crates/bevy_ecs/src/observer/mod.rs index 3b87f59291..c22ff12c5b 100644 --- a/crates/bevy_ecs/src/observer/mod.rs +++ b/crates/bevy_ecs/src/observer/mod.rs @@ -7,14 +7,22 @@ mod trigger_event; pub use runner::*; pub use trigger_event::*; -use crate::entity::EntityHashMap; -use crate::observer::entity_observer::ObservedBy; -use crate::{archetype::ArchetypeFlags, system::IntoObserverSystem, world::*}; -use crate::{component::ComponentId, prelude::*, world::DeferredWorld}; +use crate::{ + archetype::ArchetypeFlags, + component::ComponentId, + entity::EntityHashMap, + observer::entity_observer::ObservedBy, + prelude::*, + system::IntoObserverSystem, + world::{DeferredWorld, *}, +}; use bevy_ptr::Ptr; use bevy_utils::HashMap; -use std::ops::{Deref, DerefMut}; -use std::{fmt::Debug, marker::PhantomData}; +use std::{ + fmt::Debug, + marker::PhantomData, + ops::{Deref, DerefMut}, +}; /// Type containing triggered [`Event`] information for a given run of an [`Observer`]. This contains the /// [`Event`] data itself. If it was triggered for a specific [`Entity`], it includes that as well. It also @@ -525,11 +533,11 @@ mod tests { use bevy_ptr::OwningPtr; use crate as bevy_ecs; - use crate::observer::{ - EmitDynamicTrigger, Observer, ObserverDescriptor, ObserverState, OnReplace, + use crate::{ + observer::{EmitDynamicTrigger, Observer, ObserverDescriptor, ObserverState, OnReplace}, + prelude::*, + traversal::Traversal, }; - use crate::prelude::*; - use crate::traversal::Traversal; #[derive(Component)] struct A; diff --git a/crates/bevy_ecs/src/observer/runner.rs b/crates/bevy_ecs/src/observer/runner.rs index a23172fa86..87d0c35f4e 100644 --- a/crates/bevy_ecs/src/observer/runner.rs +++ b/crates/bevy_ecs/src/observer/runner.rs @@ -86,6 +86,7 @@ impl Component for ObserverState { } /// Type for function that is run when an observer is triggered. +/// /// Typically refers to the default runner that runs the system stored in the associated [`Observer`] component, /// but can be overridden for custom behaviour. pub type ObserverRunner = fn(DeferredWorld, ObserverTrigger, PtrMut, propagate: &mut bool); diff --git a/crates/bevy_ecs/src/observer/trigger_event.rs b/crates/bevy_ecs/src/observer/trigger_event.rs index ce368d9398..2c90a478ee 100644 --- a/crates/bevy_ecs/src/observer/trigger_event.rs +++ b/crates/bevy_ecs/src/observer/trigger_event.rs @@ -100,6 +100,7 @@ fn trigger_event( } /// Represents a collection of targets for a specific [`Trigger`] of an [`Event`]. Targets can be of type [`Entity`] or [`ComponentId`]. +/// /// When a trigger occurs for a given event and [`TriggerTargets`], any [`Observer`] that watches for that specific event-target combination /// will run. /// diff --git a/crates/bevy_ecs/src/query/access.rs b/crates/bevy_ecs/src/query/access.rs index 0f5fb318af..75b2b09dea 100644 --- a/crates/bevy_ecs/src/query/access.rs +++ b/crates/bevy_ecs/src/query/access.rs @@ -1,8 +1,7 @@ use crate::storage::SparseSetIndex; use core::fmt; use fixedbitset::FixedBitSet; -use std::fmt::Debug; -use std::marker::PhantomData; +use std::{fmt::Debug, marker::PhantomData}; /// A wrapper struct to make Debug representations of [`FixedBitSet`] easier /// to read, when used to store [`SparseSetIndex`]. @@ -1277,8 +1276,9 @@ impl Default for FilteredAccessSet { #[cfg(test)] mod tests { - use crate::query::access::AccessFilters; - use crate::query::{Access, AccessConflicts, FilteredAccess, FilteredAccessSet}; + use crate::query::{ + access::AccessFilters, Access, AccessConflicts, FilteredAccess, FilteredAccessSet, + }; use fixedbitset::FixedBitSet; use std::marker::PhantomData; diff --git a/crates/bevy_ecs/src/query/builder.rs b/crates/bevy_ecs/src/query/builder.rs index 2f4217e711..23c5c5a65b 100644 --- a/crates/bevy_ecs/src/query/builder.rs +++ b/crates/bevy_ecs/src/query/builder.rs @@ -1,7 +1,9 @@ use std::marker::PhantomData; -use crate::component::StorageType; -use crate::{component::ComponentId, prelude::*}; +use crate::{ + component::{ComponentId, StorageType}, + prelude::*, +}; use super::{FilteredAccess, QueryData, QueryFilter}; @@ -32,7 +34,7 @@ use super::{FilteredAccess, QueryData, QueryFilter}; /// /// // Consume the QueryState /// let (entity, b) = query.single(&world); -///``` +/// ``` pub struct QueryBuilder<'w, D: QueryData = (), F: QueryFilter = ()> { access: FilteredAccess, world: &'w mut World, @@ -275,8 +277,7 @@ impl<'w, D: QueryData, F: QueryFilter> QueryBuilder<'w, D, F> { #[cfg(test)] mod tests { use crate as bevy_ecs; - use crate::prelude::*; - use crate::world::FilteredEntityRef; + use crate::{prelude::*, world::FilteredEntityRef}; #[derive(Component, PartialEq, Debug)] struct A(usize); diff --git a/crates/bevy_ecs/src/query/iter.rs b/crates/bevy_ecs/src/query/iter.rs index 6522a1b237..836c496796 100644 --- a/crates/bevy_ecs/src/query/iter.rs +++ b/crates/bevy_ecs/src/query/iter.rs @@ -1005,7 +1005,6 @@ impl<'w, 's, D: QueryData, F: QueryFilter> QueryIter<'w, 's, D, F> { /// # Panics /// /// This will panic if `next` has been called on `QueryIter` before, unless the underlying `Query` is empty. - /// pub fn sort_by_cached_key( self, mut f: impl FnMut(&L::Item<'w>) -> K, @@ -1582,7 +1581,7 @@ impl<'w, 's, D: QueryData, F: QueryFilter, const K: usize> QueryCombinationIter< /// The lifetime here is not restrictive enough for Fetch with &mut access, /// as calling `fetch_next_aliased_unchecked` multiple times can produce multiple /// references to the same component, leading to unique reference aliasing. - ///. + /// . /// It is always safe for shared access. #[inline] unsafe fn fetch_next_aliased_unchecked(&mut self) -> Option<[D::Item<'w>; K]> { diff --git a/crates/bevy_ecs/src/query/mod.rs b/crates/bevy_ecs/src/query/mod.rs index 3102a37d14..13689c6a8c 100644 --- a/crates/bevy_ecs/src/query/mod.rs +++ b/crates/bevy_ecs/src/query/mod.rs @@ -103,16 +103,17 @@ impl DebugCheckedUnwrap for Option { #[cfg(test)] mod tests { - use crate::prelude::{AnyOf, Changed, Entity, Or, QueryState, With, Without}; - use crate::query::{ArchetypeFilter, Has, QueryCombinationIter, ReadOnlyQueryData}; - use crate::schedule::{IntoSystemConfigs, Schedule}; - use crate::system::{IntoSystem, Query, System, SystemState}; - use crate::{self as bevy_ecs, component::Component, world::World}; + use crate::{ + self as bevy_ecs, + component::Component, + prelude::{AnyOf, Changed, Entity, Or, QueryState, With, Without}, + query::{ArchetypeFilter, Has, QueryCombinationIter, ReadOnlyQueryData}, + schedule::{IntoSystemConfigs, Schedule}, + system::{IntoSystem, Query, System, SystemState}, + world::World, + }; use bevy_ecs_macros::{QueryData, QueryFilter}; - use std::any::type_name; - use std::collections::HashSet; - use std::fmt::Debug; - use std::hash::Hash; + use std::{any::type_name, collections::HashSet, fmt::Debug, hash::Hash}; #[derive(Component, Debug, Hash, Eq, PartialEq, Clone, Copy, PartialOrd, Ord)] struct A(usize); diff --git a/crates/bevy_ecs/src/query/state.rs b/crates/bevy_ecs/src/query/state.rs index 6ac740255c..ab9947f80b 100644 --- a/crates/bevy_ecs/src/query/state.rs +++ b/crates/bevy_ecs/src/query/state.rs @@ -1719,8 +1719,9 @@ impl From> for QueryState) -> &mut Self; @@ -161,7 +157,6 @@ pub trait ReflectCommandExt { /// commands.entity(prefab.entity) /// .remove_reflect(prefab.data.reflect_type_path().to_owned()); /// } - /// /// ``` fn remove_reflect(&mut self, component_type_name: impl Into>) -> &mut Self; /// Same as [`remove_reflect`](ReflectCommandExt::remove_reflect), but using the `T` resource as type registry instead of @@ -351,10 +346,15 @@ impl> Command for RemoveReflectWithRegistry #[cfg(test)] mod tests { - use crate::prelude::{AppTypeRegistry, ReflectComponent}; - use crate::reflect::{ReflectBundle, ReflectCommandExt}; - use crate::system::{Commands, SystemState}; - use crate::{self as bevy_ecs, bundle::Bundle, component::Component, world::World}; + use crate::{ + self as bevy_ecs, + bundle::Bundle, + component::Component, + prelude::{AppTypeRegistry, ReflectComponent}, + reflect::{ReflectBundle, ReflectCommandExt}, + system::{Commands, SystemState}, + world::World, + }; use bevy_ecs_macros::Resource; use bevy_reflect::{PartialReflect, Reflect, TypeRegistry}; diff --git a/crates/bevy_ecs/src/reflect/map_entities.rs b/crates/bevy_ecs/src/reflect/map_entities.rs index 4bc70acc3e..dcf8c3ae86 100644 --- a/crates/bevy_ecs/src/reflect/map_entities.rs +++ b/crates/bevy_ecs/src/reflect/map_entities.rs @@ -6,6 +6,7 @@ use crate::{ use bevy_reflect::FromType; /// For a specific type of component, this maps any fields with values of type [`Entity`] to a new world. +/// /// Since a given `Entity` ID is only valid for the world it came from, when performing deserialization /// any stored IDs need to be re-allocated in the destination world. /// @@ -75,6 +76,7 @@ impl FromType for ReflectMapEntities { } /// For a specific type of resource, this maps any fields with values of type [`Entity`] to a new world. +/// /// Since a given `Entity` ID is only valid for the world it came from, when performing deserialization /// any stored IDs need to be re-allocated in the destination world. /// diff --git a/crates/bevy_ecs/src/reflect/mod.rs b/crates/bevy_ecs/src/reflect/mod.rs index ae02af8913..c87b7f6ae1 100644 --- a/crates/bevy_ecs/src/reflect/mod.rs +++ b/crates/bevy_ecs/src/reflect/mod.rs @@ -1,13 +1,15 @@ //! Types that enable reflection support. -use std::any::TypeId; -use std::ops::{Deref, DerefMut}; +use std::{ + any::TypeId, + ops::{Deref, DerefMut}, +}; use crate as bevy_ecs; use crate::{system::Resource, world::World}; -use bevy_reflect::std_traits::ReflectDefault; use bevy_reflect::{ - PartialReflect, Reflect, ReflectFromReflect, TypePath, TypeRegistry, TypeRegistryArc, + std_traits::ReflectDefault, PartialReflect, Reflect, ReflectFromReflect, TypePath, + TypeRegistry, TypeRegistryArc, }; mod bundle; diff --git a/crates/bevy_ecs/src/schedule/condition.rs b/crates/bevy_ecs/src/schedule/condition.rs index 924f8cd0b8..e99eab07f9 100644 --- a/crates/bevy_ecs/src/schedule/condition.rs +++ b/crates/bevy_ecs/src/schedule/condition.rs @@ -1,5 +1,4 @@ -use std::borrow::Cow; -use std::ops::Not; +use std::{borrow::Cow, ops::Not}; use crate::system::{ Adapt, AdapterSystem, CombinatorSystem, Combine, IntoSystem, ReadOnlySystem, System, SystemIn, @@ -1351,12 +1350,14 @@ where mod tests { use super::{common_conditions::*, Condition}; use crate as bevy_ecs; - use crate::component::Component; - use crate::schedule::IntoSystemConfigs; - use crate::system::Local; - use crate::{change_detection::ResMut, schedule::Schedule, world::World}; - use bevy_ecs_macros::Event; - use bevy_ecs_macros::Resource; + use crate::{ + change_detection::ResMut, + component::Component, + schedule::{IntoSystemConfigs, Schedule}, + system::Local, + world::World, + }; + use bevy_ecs_macros::{Event, Resource}; #[derive(Resource, Default)] struct Counter(usize); diff --git a/crates/bevy_ecs/src/schedule/executor/mod.rs b/crates/bevy_ecs/src/schedule/executor/mod.rs index 952bf5b39d..7213ee8d72 100644 --- a/crates/bevy_ecs/src/schedule/executor/mod.rs +++ b/crates/bevy_ecs/src/schedule/executor/mod.rs @@ -2,9 +2,11 @@ mod multi_threaded; mod simple; mod single_threaded; -pub use self::multi_threaded::{MainThreadExecutor, MultiThreadedExecutor}; -pub use self::simple::SimpleExecutor; -pub use self::single_threaded::SingleThreadedExecutor; +pub use self::{ + multi_threaded::{MainThreadExecutor, MultiThreadedExecutor}, + simple::SimpleExecutor, + single_threaded::SingleThreadedExecutor, +}; use fixedbitset::FixedBitSet; @@ -127,6 +129,7 @@ pub(super) fn is_apply_deferred(system: &BoxedSystem) -> bool { } /// These functions hide the bottom of the callstack from `RUST_BACKTRACE=1` (assuming the default panic handler is used). +/// /// The full callstack will still be visible with `RUST_BACKTRACE=full`. /// They are specialized for `System::run` & co instead of being generic over closures because this avoids an /// extra frame in the backtrace. diff --git a/crates/bevy_ecs/src/schedule/executor/multi_threaded.rs b/crates/bevy_ecs/src/schedule/executor/multi_threaded.rs index 92f71362ea..141573f6f5 100644 --- a/crates/bevy_ecs/src/schedule/executor/multi_threaded.rs +++ b/crates/bevy_ecs/src/schedule/executor/multi_threaded.rs @@ -4,10 +4,9 @@ use std::{ }; use bevy_tasks::{ComputeTaskPool, Scope, TaskPool, ThreadExecutor}; -use bevy_utils::default; -use bevy_utils::syncunsafecell::SyncUnsafeCell; #[cfg(feature = "trace")] use bevy_utils::tracing::{info_span, Span}; +use bevy_utils::{default, syncunsafecell::SyncUnsafeCell}; use std::panic::AssertUnwindSafe; use concurrent_queue::ConcurrentQueue; diff --git a/crates/bevy_ecs/src/schedule/mod.rs b/crates/bevy_ecs/src/schedule/mod.rs index 28aa65c59d..6bf8276f81 100644 --- a/crates/bevy_ecs/src/schedule/mod.rs +++ b/crates/bevy_ecs/src/schedule/mod.rs @@ -9,12 +9,8 @@ mod schedule; mod set; mod stepping; -pub use self::condition::*; -pub use self::config::*; -pub use self::executor::*; use self::graph_utils::*; -pub use self::schedule::*; -pub use self::set::*; +pub use self::{condition::*, config::*, executor::*, schedule::*, set::*}; pub use self::graph_utils::NodeId; @@ -24,9 +20,11 @@ mod tests { use std::sync::atomic::{AtomicU32, Ordering}; pub use crate as bevy_ecs; - pub use crate::schedule::{Schedule, SystemSet}; - pub use crate::system::{Res, ResMut}; - pub use crate::{prelude::World, system::Resource}; + pub use crate::{ + prelude::World, + schedule::{Schedule, SystemSet}, + system::{Res, ResMut, Resource}, + }; #[derive(SystemSet, Clone, Debug, PartialEq, Eq, Hash)] enum TestSet { @@ -1158,7 +1156,7 @@ mod tests { world.allow_ambiguous_resource::(); let mut schedule = Schedule::new(TestSchedule); - //check resource + // check resource schedule.add_systems((resmut_system, res_system)); schedule.initialize(&mut world).unwrap(); assert!(schedule.graph().conflicting_systems().is_empty()); diff --git a/crates/bevy_ecs/src/schedule/schedule.rs b/crates/bevy_ecs/src/schedule/schedule.rs index 83d0fbc644..f0d7642fa5 100644 --- a/crates/bevy_ecs/src/schedule/schedule.rs +++ b/crates/bevy_ecs/src/schedule/schedule.rs @@ -5,9 +5,9 @@ use std::{ #[cfg(feature = "trace")] use bevy_utils::tracing::info_span; -use bevy_utils::{default, tracing::info}; use bevy_utils::{ - tracing::{error, warn}, + default, + tracing::{error, info, warn}, HashMap, HashSet, }; use disqualified::ShortName; @@ -24,8 +24,7 @@ use crate::{ world::World, }; -use crate::query::AccessConflicts; -use crate::storage::SparseSetIndex; +use crate::{query::AccessConflicts, storage::SparseSetIndex}; pub use stepping::Stepping; /// Resource that stores [`Schedule`]s mapped to [`ScheduleLabel`]s excluding the current running [`Schedule`]. diff --git a/crates/bevy_ecs/src/schedule/set.rs b/crates/bevy_ecs/src/schedule/set.rs index a39efdb41b..0a408551d2 100644 --- a/crates/bevy_ecs/src/schedule/set.rs +++ b/crates/bevy_ecs/src/schedule/set.rs @@ -1,7 +1,9 @@ -use std::any::TypeId; -use std::fmt::Debug; -use std::hash::{Hash, Hasher}; -use std::marker::PhantomData; +use std::{ + any::TypeId, + fmt::Debug, + hash::{Hash, Hasher}, + marker::PhantomData, +}; pub use crate::label::DynEq; pub use bevy_ecs_macros::{ScheduleLabel, SystemSet}; diff --git a/crates/bevy_ecs/src/schedule/stepping.rs b/crates/bevy_ecs/src/schedule/stepping.rs index 822e69f16d..878ec01317 100644 --- a/crates/bevy_ecs/src/schedule/stepping.rs +++ b/crates/bevy_ecs/src/schedule/stepping.rs @@ -1,6 +1,5 @@ use fixedbitset::FixedBitSet; -use std::any::TypeId; -use std::collections::HashMap; +use std::{any::TypeId, collections::HashMap}; use crate::{ schedule::{InternedScheduleLabel, NodeId, Schedule, ScheduleLabel}, @@ -827,8 +826,7 @@ impl ScheduleState { #[cfg(all(test, feature = "bevy_debug_stepping"))] mod tests { use super::*; - use crate::prelude::*; - use crate::schedule::ScheduleLabel; + use crate::{prelude::*, schedule::ScheduleLabel}; pub use crate as bevy_ecs; diff --git a/crates/bevy_ecs/src/storage/resource.rs b/crates/bevy_ecs/src/storage/resource.rs index fec0ca86d6..edbcf325f0 100644 --- a/crates/bevy_ecs/src/storage/resource.rs +++ b/crates/bevy_ecs/src/storage/resource.rs @@ -1,7 +1,9 @@ -use crate::archetype::ArchetypeComponentId; -use crate::change_detection::{MaybeLocation, MaybeUnsafeCellLocation, MutUntyped, TicksMut}; -use crate::component::{ComponentId, ComponentTicks, Components, Tick, TickCells}; -use crate::storage::{blob_vec::BlobVec, SparseSet}; +use crate::{ + archetype::ArchetypeComponentId, + change_detection::{MaybeLocation, MaybeUnsafeCellLocation, MutUntyped, TicksMut}, + component::{ComponentId, ComponentTicks, Components, Tick, TickCells}, + storage::{blob_vec::BlobVec, SparseSet}, +}; use bevy_ptr::{OwningPtr, Ptr, UnsafeCellDeref}; #[cfg(feature = "track_change_detection")] use std::panic::Location; diff --git a/crates/bevy_ecs/src/storage/table/column.rs b/crates/bevy_ecs/src/storage/table/column.rs index ccc930d552..81535b6d48 100644 --- a/crates/bevy_ecs/src/storage/table/column.rs +++ b/crates/bevy_ecs/src/storage/table/column.rs @@ -6,6 +6,7 @@ use crate::{ use bevy_ptr::PtrMut; /// Very similar to a normal [`Column`], but with the capacities and lengths cut out for performance reasons. +/// /// This type is used by [`Table`], because all of the capacities and lengths of the [`Table`]'s columns must match. /// /// Like many other low-level storage types, [`ThinColumn`] has a limited and highly unsafe @@ -411,7 +412,6 @@ impl Column { /// /// # Safety /// `row` must be within the range `[0, self.len())`. - /// #[inline] pub(crate) unsafe fn swap_remove_unchecked(&mut self, row: TableRow) { self.data.swap_remove_and_drop_unchecked(row.as_usize()); diff --git a/crates/bevy_ecs/src/storage/table/mod.rs b/crates/bevy_ecs/src/storage/table/mod.rs index c08b49c336..e158124617 100644 --- a/crates/bevy_ecs/src/storage/table/mod.rs +++ b/crates/bevy_ecs/src/storage/table/mod.rs @@ -10,9 +10,10 @@ use bevy_utils::HashMap; pub use column::*; #[cfg(feature = "track_change_detection")] use std::panic::Location; -use std::{alloc::Layout, num::NonZeroUsize}; use std::{ + alloc::Layout, cell::UnsafeCell, + num::NonZeroUsize, ops::{Index, IndexMut}, }; mod column; @@ -814,13 +815,11 @@ impl Drop for Table { #[cfg(test)] mod tests { use crate as bevy_ecs; - use crate::component::Component; - use crate::ptr::OwningPtr; - use crate::storage::Storages; use crate::{ - component::{Components, Tick}, + component::{Component, Components, Tick}, entity::Entity, - storage::{TableBuilder, TableRow}, + ptr::OwningPtr, + storage::{Storages, TableBuilder, TableRow}, }; #[cfg(feature = "track_change_detection")] use std::panic::Location; diff --git a/crates/bevy_ecs/src/storage/thin_array_ptr.rs b/crates/bevy_ecs/src/storage/thin_array_ptr.rs index d5c36e1f04..888cd65b5b 100644 --- a/crates/bevy_ecs/src/storage/thin_array_ptr.rs +++ b/crates/bevy_ecs/src/storage/thin_array_ptr.rs @@ -1,8 +1,10 @@ use crate::query::DebugCheckedUnwrap; -use std::alloc::{alloc, handle_alloc_error, realloc, Layout}; -use std::mem::{needs_drop, size_of}; -use std::num::NonZeroUsize; -use std::ptr::{self, NonNull}; +use std::{ + alloc::{alloc, handle_alloc_error, realloc, Layout}, + mem::{needs_drop, size_of}, + num::NonZeroUsize, + ptr::{self, NonNull}, +}; /// Similar to [`Vec`], but with the capacity and length cut out for performance reasons. /// diff --git a/crates/bevy_ecs/src/system/builder.rs b/crates/bevy_ecs/src/system/builder.rs index b9734e4177..51b587512c 100644 --- a/crates/bevy_ecs/src/system/builder.rs +++ b/crates/bevy_ecs/src/system/builder.rs @@ -71,7 +71,7 @@ use super::{init_query_param, Res, ResMut, Resource, SystemState}; /// .build_system(single_parameter_system); /// /// world.run_system_once(system); -///``` +/// ``` /// /// # Safety /// @@ -227,6 +227,7 @@ unsafe impl> SystemParamBuilder> } /// A [`SystemParamBuilder`] for a [`ParamSet`]. +/// /// To build a [`ParamSet`] with a tuple of system parameters, pass a tuple of matching [`SystemParamBuilder`]s. /// To build a [`ParamSet`] with a `Vec` of system parameters, pass a `Vec` of matching [`SystemParamBuilder`]s. pub struct ParamSetBuilder(pub T); @@ -348,9 +349,11 @@ unsafe impl<'s, T: FromWorld + Send + 'static> SystemParamBuilder> #[cfg(test)] mod tests { use crate as bevy_ecs; - use crate::entity::Entities; - use crate::prelude::{Component, Query}; - use crate::system::{Local, RunSystemOnce}; + use crate::{ + entity::Entities, + prelude::{Component, Query}, + system::{Local, RunSystemOnce}, + }; use super::*; diff --git a/crates/bevy_ecs/src/system/commands/mod.rs b/crates/bevy_ecs/src/system/commands/mod.rs index 8220d38021..a3bbf8eb37 100644 --- a/crates/bevy_ecs/src/system/commands/mod.rs +++ b/crates/bevy_ecs/src/system/commands/mod.rs @@ -1777,6 +1777,7 @@ unsafe fn insert_by_id( } /// An [`EntityCommand`] that removes components from an entity. +/// /// For a [`Bundle`] type `T`, this will remove any components in the bundle. /// Any components in the bundle that aren't found on the entity will be ignored. fn remove(entity: Entity, world: &mut World) { @@ -1807,6 +1808,7 @@ fn clear() -> impl EntityCommand { } /// An [`EntityCommand`] that removes components from an entity. +/// /// For a [`Bundle`] type `T`, this will remove all components except those in the bundle. /// Any components in the bundle that aren't found on the entity will be ignored. fn retain(entity: Entity, world: &mut World) { diff --git a/crates/bevy_ecs/src/system/commands/parallel_scope.rs b/crates/bevy_ecs/src/system/commands/parallel_scope.rs index 865b6eb2b8..582825aa79 100644 --- a/crates/bevy_ecs/src/system/commands/parallel_scope.rs +++ b/crates/bevy_ecs/src/system/commands/parallel_scope.rs @@ -39,7 +39,7 @@ struct ParallelCommandQueue { /// }); /// } /// # bevy_ecs::system::assert_is_system(parallel_command_system); -///``` +/// ``` #[derive(SystemParam)] pub struct ParallelCommands<'w, 's> { state: Deferred<'s, ParallelCommandQueue>, diff --git a/crates/bevy_ecs/src/system/exclusive_system_param.rs b/crates/bevy_ecs/src/system/exclusive_system_param.rs index 255da95fec..786fd1311d 100644 --- a/crates/bevy_ecs/src/system/exclusive_system_param.rs +++ b/crates/bevy_ecs/src/system/exclusive_system_param.rs @@ -4,8 +4,7 @@ use crate::{ system::{Local, SystemMeta, SystemParam, SystemState}, world::World, }; -use bevy_utils::all_tuples; -use bevy_utils::synccell::SyncCell; +use bevy_utils::{all_tuples, synccell::SyncCell}; use std::marker::PhantomData; /// A parameter that can be used in an exclusive system (a system with an `&mut World` parameter). @@ -125,9 +124,7 @@ all_tuples!( #[cfg(test)] mod tests { use crate as bevy_ecs; - use crate::schedule::Schedule; - use crate::system::Local; - use crate::world::World; + use crate::{schedule::Schedule, system::Local, world::World}; use bevy_ecs_macros::Resource; use std::marker::PhantomData; diff --git a/crates/bevy_ecs/src/system/mod.rs b/crates/bevy_ecs/src/system/mod.rs index c3781d96fb..c84dcf6102 100644 --- a/crates/bevy_ecs/src/system/mod.rs +++ b/crates/bevy_ecs/src/system/mod.rs @@ -307,8 +307,6 @@ mod tests { use bevy_utils::default; use std::any::TypeId; - use crate::prelude::EntityRef; - use crate::world::EntityMut; use crate::{ self as bevy_ecs, archetype::{ArchetypeComponentId, Archetypes}, @@ -316,7 +314,7 @@ mod tests { change_detection::DetectChanges, component::{Component, Components, Tick}, entity::{Entities, Entity}, - prelude::AnyOf, + prelude::{AnyOf, EntityRef}, query::{Added, Changed, Or, With, Without}, removal_detection::RemovedComponents, schedule::{ @@ -327,7 +325,7 @@ mod tests { Commands, In, IntoSystem, Local, NonSend, NonSendMut, ParamSet, Query, Res, ResMut, Resource, StaticSystemParam, System, SystemState, }, - world::{FromWorld, World}, + world::{EntityMut, FromWorld, World}, }; #[derive(Resource, PartialEq, Debug)] diff --git a/crates/bevy_ecs/src/system/system.rs b/crates/bevy_ecs/src/system/system.rs index 296bf8ea2d..8f7a800b91 100644 --- a/crates/bevy_ecs/src/system/system.rs +++ b/crates/bevy_ecs/src/system/system.rs @@ -1,16 +1,16 @@ use bevy_utils::tracing::warn; use core::fmt::Debug; -use crate::component::Tick; -use crate::schedule::InternedSystemSet; -use crate::system::input::SystemInput; -use crate::system::SystemIn; -use crate::world::unsafe_world_cell::UnsafeWorldCell; -use crate::world::DeferredWorld; -use crate::{archetype::ArchetypeComponentId, component::ComponentId, query::Access, world::World}; +use crate::{ + archetype::ArchetypeComponentId, + component::{ComponentId, Tick}, + query::Access, + schedule::InternedSystemSet, + system::{input::SystemInput, SystemIn}, + world::{unsafe_world_cell::UnsafeWorldCell, DeferredWorld, World}, +}; -use std::any::TypeId; -use std::borrow::Cow; +use std::{any::TypeId, borrow::Cow}; use super::IntoSystem; diff --git a/crates/bevy_ecs/src/system/system_name.rs b/crates/bevy_ecs/src/system/system_name.rs index a158a8327c..584cc3e4a1 100644 --- a/crates/bevy_ecs/src/system/system_name.rs +++ b/crates/bevy_ecs/src/system/system_name.rs @@ -1,9 +1,10 @@ -use crate::component::Tick; -use crate::prelude::World; -use crate::system::{ExclusiveSystemParam, ReadOnlySystemParam, SystemMeta, SystemParam}; -use crate::world::unsafe_world_cell::UnsafeWorldCell; -use std::borrow::Cow; -use std::ops::Deref; +use crate::{ + component::Tick, + prelude::World, + system::{ExclusiveSystemParam, ReadOnlySystemParam, SystemMeta, SystemParam}, + world::unsafe_world_cell::UnsafeWorldCell, +}; +use std::{borrow::Cow, ops::Deref}; /// [`SystemParam`] that returns the name of the system which it is used in. /// @@ -105,8 +106,10 @@ impl ExclusiveSystemParam for SystemName<'_> { #[cfg(test)] mod tests { - use crate::system::{IntoSystem, RunSystemOnce, SystemName}; - use crate::world::World; + use crate::{ + system::{IntoSystem, RunSystemOnce, SystemName}, + world::World, + }; #[test] fn test_system_name_regular_param() { diff --git a/crates/bevy_ecs/src/system/system_param.rs b/crates/bevy_ecs/src/system/system_param.rs index 4b7d69eff9..916fbeb969 100644 --- a/crates/bevy_ecs/src/system/system_param.rs +++ b/crates/bevy_ecs/src/system/system_param.rs @@ -1,5 +1,4 @@ pub use crate::change_detection::{NonSendMut, Res, ResMut}; -use crate::storage::SparseSetIndex; use crate::{ archetype::{Archetype, Archetypes}, bundle::Bundles, @@ -7,16 +6,15 @@ use crate::{ component::{ComponentId, ComponentTicks, Components, Tick}, entity::Entities, query::{ - Access, FilteredAccess, FilteredAccessSet, QueryData, QueryFilter, QueryState, - ReadOnlyQueryData, + Access, AccessConflicts, FilteredAccess, FilteredAccessSet, QueryData, QueryFilter, + QueryState, ReadOnlyQueryData, }, + storage::{ResourceData, SparseSetIndex}, system::{Query, SystemMeta}, world::{unsafe_world_cell::UnsafeWorldCell, DeferredWorld, FromWorld, World}, }; -use crate::{query::AccessConflicts, storage::ResourceData}; use bevy_ecs_macros::impl_param_set; -pub use bevy_ecs_macros::Resource; -pub use bevy_ecs_macros::SystemParam; +pub use bevy_ecs_macros::{Resource, SystemParam}; use bevy_ptr::UnsafeCellDeref; use bevy_utils::{all_tuples, synccell::SyncCell}; #[cfg(feature = "track_change_detection")] @@ -69,7 +67,7 @@ use std::{ /// # eventwriter: /// EventWriter<'w, SomeEvent> /// # } -///``` +/// ``` /// ## `PhantomData` /// /// [`PhantomData`] is a special type of `SystemParam` that does nothing. @@ -494,7 +492,7 @@ fn assert_component_access_compatibility( /// )),) /// .build_state(&mut world) /// .build_system(buildable_system); -///world.run_system_once(system); +/// world.run_system_once(system); /// /// fn buildable_system(mut set: ParamSet<(Query<&mut Health>, Query<&mut Health>, &World)>) { /// // The first parameter is built from the first builder, @@ -1874,7 +1872,6 @@ pub mod lifetimeless { /// # bevy_ecs::system::assert_is_system(do_thing_generically::); /// # } /// ``` -/// pub struct StaticSystemParam<'w, 's, P: SystemParam>(SystemParamItem<'w, 's, P>); impl<'w, 's, P: SystemParam> Deref for StaticSystemParam<'w, 's, P> { @@ -1973,6 +1970,7 @@ unsafe impl SystemParam for PhantomData { unsafe impl ReadOnlySystemParam for PhantomData {} /// A [`SystemParam`] with a type that can be configured at runtime. +/// /// To be useful, this must be configured using a [`DynParamBuilder`](crate::system::DynParamBuilder) to build the system using a [`SystemParamBuilder`](crate::prelude::SystemParamBuilder). /// /// # Examples diff --git a/crates/bevy_ecs/src/system/system_registry.rs b/crates/bevy_ecs/src/system/system_registry.rs index 3374f1b15a..be08995cd9 100644 --- a/crates/bevy_ecs/src/system/system_registry.rs +++ b/crates/bevy_ecs/src/system/system_registry.rs @@ -1,10 +1,11 @@ -use crate::bundle::Bundle; -use crate::change_detection::Mut; -use crate::entity::Entity; -use crate::system::input::SystemInput; -use crate::system::{BoxedSystem, IntoSystem, System, SystemIn}; -use crate::world::{Command, World}; -use crate::{self as bevy_ecs}; +use crate::{ + bundle::Bundle, + change_detection::Mut, + entity::Entity, + system::{input::SystemInput, BoxedSystem, IntoSystem, System, SystemIn}, + world::{Command, World}, + {self as bevy_ecs}, +}; use bevy_ecs_macros::{Component, Resource}; use thiserror::Error; diff --git a/crates/bevy_ecs/src/world/command_queue.rs b/crates/bevy_ecs/src/world/command_queue.rs index e78ce8b03e..4183493a84 100644 --- a/crates/bevy_ecs/src/world/command_queue.rs +++ b/crates/bevy_ecs/src/world/command_queue.rs @@ -26,7 +26,6 @@ struct CommandMeta { } /// Densely and efficiently stores a queue of heterogenous types implementing [`Command`]. -// // NOTE: [`CommandQueue`] is implemented via a `Vec>` instead of a `Vec>` // as an optimization. Since commands are used frequently in systems as a way to spawn // entities/components/resources, and it's not currently possible to parallelize these diff --git a/crates/bevy_ecs/src/world/entity_ref.rs b/crates/bevy_ecs/src/world/entity_ref.rs index 6fd1fa5b25..5477e79c3f 100644 --- a/crates/bevy_ecs/src/world/entity_ref.rs +++ b/crates/bevy_ecs/src/world/entity_ref.rs @@ -555,6 +555,7 @@ impl<'a> TryFrom<&'a mut FilteredEntityMut<'_>> for EntityMut<'a> { } /// A mutable reference to a particular [`Entity`], and the entire world. +/// /// This is essentially a performance-optimized `(Entity, &mut World)` tuple, /// which caches the [`EntityLocation`] to reduce duplicate lookups. /// @@ -1049,7 +1050,6 @@ impl<'w> EntityWorldMut<'w> { /// this fn as if the code here was written inline /// /// when DROP is true removed components will be dropped otherwise they will be forgotten - /// // We use a const generic here so that we are less reliant on // inlining for rustc to optimize out the `match DROP` #[allow(clippy::too_many_arguments)] @@ -1488,7 +1488,6 @@ impl<'w> EntityWorldMut<'w> { /// # let mut entity = world.get_entity_mut(entity_id).unwrap(); /// entity.entry::().and_modify(|mut c| c.0 += 1); /// assert_eq!(world.query::<&Comp>().single(&world).0, 5); - /// /// ``` pub fn entry<'a, T: Component>(&'a mut self) -> Entry<'w, 'a, T> { if self.contains::() { @@ -2787,9 +2786,13 @@ mod tests { use bevy_ptr::OwningPtr; use std::panic::AssertUnwindSafe; - use crate::system::RunSystemOnce as _; - use crate::world::{FilteredEntityMut, FilteredEntityRef}; - use crate::{self as bevy_ecs, component::ComponentId, prelude::*, system::assert_is_system}; + use crate::{ + self as bevy_ecs, + component::ComponentId, + prelude::*, + system::{assert_is_system, RunSystemOnce as _}, + world::{FilteredEntityMut, FilteredEntityRef}, + }; use super::{EntityMutExcept, EntityRefExcept}; diff --git a/crates/bevy_ecs/src/world/identifier.rs b/crates/bevy_ecs/src/world/identifier.rs index 1c1fd93c3b..0e581b368f 100644 --- a/crates/bevy_ecs/src/world/identifier.rs +++ b/crates/bevy_ecs/src/world/identifier.rs @@ -1,8 +1,7 @@ -use crate::system::{ExclusiveSystemParam, SystemMeta}; use crate::{ component::Tick, storage::SparseSetIndex, - system::{ReadOnlySystemParam, SystemParam}, + system::{ExclusiveSystemParam, ReadOnlySystemParam, SystemMeta, SystemParam}, world::{FromWorld, World}, }; use std::sync::atomic::{AtomicUsize, Ordering}; diff --git a/crates/bevy_ecs/src/world/reflect.rs b/crates/bevy_ecs/src/world/reflect.rs index 2609d4e416..92add787d1 100644 --- a/crates/bevy_ecs/src/world/reflect.rs +++ b/crates/bevy_ecs/src/world/reflect.rs @@ -6,8 +6,7 @@ use thiserror::Error; use bevy_reflect::{Reflect, ReflectFromPtr}; -use crate::prelude::*; -use crate::world::ComponentId; +use crate::{prelude::*, world::ComponentId}; impl World { /// Retrieves a reference to the given `entity`'s [`Component`] of the given `type_id` using diff --git a/crates/bevy_ecs/src/world/unsafe_world_cell.rs b/crates/bevy_ecs/src/world/unsafe_world_cell.rs index 7aac53742d..e8d0fb6eb1 100644 --- a/crates/bevy_ecs/src/world/unsafe_world_cell.rs +++ b/crates/bevy_ecs/src/world/unsafe_world_cell.rs @@ -568,7 +568,6 @@ impl<'w> UnsafeWorldCell<'w> { } // Shorthand helper function for getting the data and change ticks for a resource. - /// /// # Safety /// It is the callers responsibility to ensure that /// - the [`UnsafeWorldCell`] has permission to access the resource mutably @@ -589,7 +588,6 @@ impl<'w> UnsafeWorldCell<'w> { } // Shorthand helper function for getting the data and change ticks for a resource. - /// /// # Panics /// This function will panic if it isn't called from the same thread that the resource was inserted from. /// diff --git a/crates/bevy_gilrs/src/gilrs_system.rs b/crates/bevy_gilrs/src/gilrs_system.rs index 331bccb0ca..6a54249be7 100644 --- a/crates/bevy_gilrs/src/gilrs_system.rs +++ b/crates/bevy_gilrs/src/gilrs_system.rs @@ -2,17 +2,20 @@ use crate::{ converter::{convert_axis, convert_button, convert_gamepad_id}, Gilrs, }; -use bevy_ecs::event::EventWriter; #[cfg(target_arch = "wasm32")] use bevy_ecs::system::NonSendMut; -use bevy_ecs::system::{Res, ResMut}; -use bevy_input::gamepad::{ - GamepadAxisChangedEvent, GamepadButtonChangedEvent, GamepadConnection, GamepadConnectionEvent, - GamepadSettings, +use bevy_ecs::{ + event::EventWriter, + system::{Res, ResMut}, +}; +use bevy_input::{ + gamepad::{ + GamepadAxisChangedEvent, GamepadButtonChangedEvent, GamepadConnection, + GamepadConnectionEvent, GamepadEvent, GamepadInfo, GamepadSettings, + }, + prelude::{GamepadAxis, GamepadButton}, + Axis, }; -use bevy_input::gamepad::{GamepadEvent, GamepadInfo}; -use bevy_input::prelude::{GamepadAxis, GamepadButton}; -use bevy_input::Axis; use gilrs::{ev::filter::axis_dpad_to_button, EventType, Filter}; pub fn gilrs_event_startup_system( diff --git a/crates/bevy_gilrs/src/rumble.rs b/crates/bevy_gilrs/src/rumble.rs index b59abef9a0..4d96ca4e30 100644 --- a/crates/bevy_gilrs/src/rumble.rs +++ b/crates/bevy_gilrs/src/rumble.rs @@ -5,8 +5,11 @@ use bevy_ecs::prelude::{EventReader, Res, ResMut, Resource}; use bevy_ecs::system::NonSendMut; use bevy_input::gamepad::{GamepadRumbleIntensity, GamepadRumbleRequest}; use bevy_time::{Real, Time}; -use bevy_utils::tracing::{debug, warn}; -use bevy_utils::{synccell::SyncCell, Duration, HashMap}; +use bevy_utils::{ + synccell::SyncCell, + tracing::{debug, warn}, + Duration, HashMap, +}; use gilrs::{ ff::{self, BaseEffect, BaseEffectType, Repeat, Replay}, GamepadId, diff --git a/crates/bevy_gizmos/src/arcs.rs b/crates/bevy_gizmos/src/arcs.rs index c3b96f75dc..204d927f59 100644 --- a/crates/bevy_gizmos/src/arcs.rs +++ b/crates/bevy_gizmos/src/arcs.rs @@ -3,8 +3,10 @@ //! Includes the implementation of [`Gizmos::arc_2d`], //! and assorted support items. -use crate::circles::DEFAULT_CIRCLE_RESOLUTION; -use crate::prelude::{GizmoConfigGroup, Gizmos}; +use crate::{ + circles::DEFAULT_CIRCLE_RESOLUTION, + prelude::{GizmoConfigGroup, Gizmos}, +}; use bevy_color::Color; use bevy_math::{Isometry2d, Isometry3d, Quat, Rot2, Vec2, Vec3}; use std::f32::consts::{FRAC_PI_2, TAU}; diff --git a/crates/bevy_gizmos/src/circles.rs b/crates/bevy_gizmos/src/circles.rs index 1f63aed486..9e9a408bbe 100644 --- a/crates/bevy_gizmos/src/circles.rs +++ b/crates/bevy_gizmos/src/circles.rs @@ -5,8 +5,7 @@ use crate::prelude::{GizmoConfigGroup, Gizmos}; use bevy_color::Color; -use bevy_math::{ops, Isometry2d, Isometry3d}; -use bevy_math::{Quat, Vec2, Vec3}; +use bevy_math::{ops, Isometry2d, Isometry3d, Quat, Vec2, Vec3}; use std::f32::consts::TAU; pub(crate) const DEFAULT_CIRCLE_RESOLUTION: u32 = 32; diff --git a/crates/bevy_gizmos/src/gizmos.rs b/crates/bevy_gizmos/src/gizmos.rs index da66a8981d..7f50221978 100644 --- a/crates/bevy_gizmos/src/gizmos.rs +++ b/crates/bevy_gizmos/src/gizmos.rs @@ -13,8 +13,7 @@ use bevy_transform::TransformPoint; use bevy_utils::default; use crate::{ - config::GizmoConfigGroup, - config::{DefaultGizmoConfigGroup, GizmoConfigStore}, + config::{DefaultGizmoConfigGroup, GizmoConfigGroup, GizmoConfigStore}, prelude::GizmoConfig, }; diff --git a/crates/bevy_gizmos/src/grid.rs b/crates/bevy_gizmos/src/grid.rs index 7e637c54e1..55e611d767 100644 --- a/crates/bevy_gizmos/src/grid.rs +++ b/crates/bevy_gizmos/src/grid.rs @@ -5,8 +5,7 @@ use crate::prelude::{GizmoConfigGroup, Gizmos}; use bevy_color::Color; -use bevy_math::Vec3Swizzles; -use bevy_math::{ops, Isometry2d, Isometry3d, Quat, UVec2, UVec3, Vec2, Vec3}; +use bevy_math::{ops, Isometry2d, Isometry3d, Quat, UVec2, UVec3, Vec2, Vec3, Vec3Swizzles}; /// A builder returned by [`Gizmos::grid_3d`] pub struct GridBuilder3d<'a, 'w, 's, Config, Clear> diff --git a/crates/bevy_gizmos/src/primitives/dim2.rs b/crates/bevy_gizmos/src/primitives/dim2.rs index 7d0d3850a1..bc20326c2e 100644 --- a/crates/bevy_gizmos/src/primitives/dim2.rs +++ b/crates/bevy_gizmos/src/primitives/dim2.rs @@ -5,12 +5,14 @@ use std::f32::consts::{FRAC_PI_2, PI}; use super::helpers::*; use bevy_color::Color; -use bevy_math::primitives::{ - Annulus, Arc2d, BoxedPolygon, BoxedPolyline2d, Capsule2d, Circle, CircularSector, - CircularSegment, Ellipse, Line2d, Plane2d, Polygon, Polyline2d, Primitive2d, Rectangle, - RegularPolygon, Rhombus, Segment2d, Triangle2d, +use bevy_math::{ + primitives::{ + Annulus, Arc2d, BoxedPolygon, BoxedPolyline2d, Capsule2d, Circle, CircularSector, + CircularSegment, Ellipse, Line2d, Plane2d, Polygon, Polyline2d, Primitive2d, Rectangle, + RegularPolygon, Rhombus, Segment2d, Triangle2d, + }, + Dir2, Isometry2d, Rot2, Vec2, }; -use bevy_math::{Dir2, Isometry2d, Rot2, Vec2}; use crate::prelude::{GizmoConfigGroup, Gizmos}; @@ -43,7 +45,10 @@ where Config: GizmoConfigGroup, Clear: 'static + Send + Sync, { - type Output<'a> = () where Self : 'a; + type Output<'a> + = () + where + Self: 'a; fn primitive_2d( &mut self, @@ -67,7 +72,10 @@ where Config: GizmoConfigGroup, Clear: 'static + Send + Sync, { - type Output<'a> = () where Self: 'a; + type Output<'a> + = () + where + Self: 'a; fn primitive_2d( &mut self, @@ -97,7 +105,10 @@ where Config: GizmoConfigGroup, Clear: 'static + Send + Sync, { - type Output<'a> = crate::circles::Ellipse2dBuilder<'a, 'w, 's, Config, Clear> where Self: 'a; + type Output<'a> + = crate::circles::Ellipse2dBuilder<'a, 'w, 's, Config, Clear> + where + Self: 'a; fn primitive_2d( &mut self, @@ -116,7 +127,10 @@ where Config: GizmoConfigGroup, Clear: 'static + Send + Sync, { - type Output<'a> = () where Self: 'a; + type Output<'a> + = () + where + Self: 'a; fn primitive_2d( &mut self, @@ -155,7 +169,10 @@ where Config: GizmoConfigGroup, Clear: 'static + Send + Sync, { - type Output<'a> = () where Self: 'a; + type Output<'a> + = () + where + Self: 'a; fn primitive_2d( &mut self, @@ -193,7 +210,10 @@ where Config: GizmoConfigGroup, Clear: 'static + Send + Sync, { - type Output<'a> = crate::circles::Ellipse2dBuilder<'a, 'w, 's, Config, Clear> where Self: 'a; + type Output<'a> + = crate::circles::Ellipse2dBuilder<'a, 'w, 's, Config, Clear> + where + Self: 'a; fn primitive_2d<'a>( &mut self, @@ -252,7 +272,10 @@ where Config: GizmoConfigGroup, Clear: 'static + Send + Sync, { - type Output<'a> = Annulus2dBuilder<'a, 'w, 's, Config, Clear> where Self: 'a; + type Output<'a> + = Annulus2dBuilder<'a, 'w, 's, Config, Clear> + where + Self: 'a; fn primitive_2d( &mut self, @@ -309,7 +332,10 @@ where Config: GizmoConfigGroup, Clear: 'static + Send + Sync, { - type Output<'a> = () where Self: 'a; + type Output<'a> + = () + where + Self: 'a; fn primitive_2d( &mut self, @@ -339,7 +365,10 @@ where Config: GizmoConfigGroup, Clear: 'static + Send + Sync, { - type Output<'a> = () where Self: 'a; + type Output<'a> + = () + where + Self: 'a; fn primitive_2d( &mut self, @@ -428,7 +457,10 @@ where Config: GizmoConfigGroup, Clear: 'static + Send + Sync, { - type Output<'a> = Line2dBuilder<'a, 'w, 's, Config, Clear> where Self: 'a; + type Output<'a> + = Line2dBuilder<'a, 'w, 's, Config, Clear> + where + Self: 'a; fn primitive_2d( &mut self, @@ -483,7 +515,10 @@ where Config: GizmoConfigGroup, Clear: 'static + Send + Sync, { - type Output<'a> = () where Self: 'a; + type Output<'a> + = () + where + Self: 'a; fn primitive_2d( &mut self, @@ -561,7 +596,10 @@ where Config: GizmoConfigGroup, Clear: 'static + Send + Sync, { - type Output<'a> = Segment2dBuilder<'a, 'w, 's, Config, Clear> where Self: 'a; + type Output<'a> + = Segment2dBuilder<'a, 'w, 's, Config, Clear> + where + Self: 'a; fn primitive_2d( &mut self, @@ -612,7 +650,10 @@ where Config: GizmoConfigGroup, Clear: 'static + Send + Sync, { - type Output<'a> = () where Self: 'a; + type Output<'a> + = () + where + Self: 'a; fn primitive_2d( &mut self, @@ -642,7 +683,10 @@ where Config: GizmoConfigGroup, Clear: 'static + Send + Sync, { - type Output<'a> = () where Self: 'a; + type Output<'a> + = () + where + Self: 'a; fn primitive_2d( &mut self, @@ -672,7 +716,10 @@ where Config: GizmoConfigGroup, Clear: 'static + Send + Sync, { - type Output<'a> = () where Self: 'a; + type Output<'a> + = () + where + Self: 'a; fn primitive_2d( &mut self, @@ -696,7 +743,10 @@ where Config: GizmoConfigGroup, Clear: 'static + Send + Sync, { - type Output<'a> = () where Self: 'a; + type Output<'a> + = () + where + Self: 'a; fn primitive_2d( &mut self, @@ -728,7 +778,10 @@ where Config: GizmoConfigGroup, Clear: 'static + Send + Sync, { - type Output<'a> = () where Self: 'a; + type Output<'a> + = () + where + Self: 'a; fn primitive_2d( &mut self, @@ -768,7 +821,10 @@ where Config: GizmoConfigGroup, Clear: 'static + Send + Sync, { - type Output<'a> = () where Self: 'a; + type Output<'a> + = () + where + Self: 'a; fn primitive_2d( &mut self, @@ -806,7 +862,10 @@ where Config: GizmoConfigGroup, Clear: 'static + Send + Sync, { - type Output<'a> = () where Self: 'a; + type Output<'a> + = () + where + Self: 'a; fn primitive_2d( &mut self, diff --git a/crates/bevy_gizmos/src/primitives/dim3.rs b/crates/bevy_gizmos/src/primitives/dim3.rs index f2ee075c16..6a4caa3a00 100644 --- a/crates/bevy_gizmos/src/primitives/dim3.rs +++ b/crates/bevy_gizmos/src/primitives/dim3.rs @@ -3,14 +3,18 @@ use super::helpers::*; use bevy_color::Color; -use bevy_math::primitives::{ - BoxedPolyline3d, Capsule3d, Cone, ConicalFrustum, Cuboid, Cylinder, Line3d, Plane3d, - Polyline3d, Primitive3d, Segment3d, Sphere, Tetrahedron, Torus, Triangle3d, +use bevy_math::{ + primitives::{ + BoxedPolyline3d, Capsule3d, Cone, ConicalFrustum, Cuboid, Cylinder, Line3d, Plane3d, + Polyline3d, Primitive3d, Segment3d, Sphere, Tetrahedron, Torus, Triangle3d, + }, + Dir3, Isometry3d, Quat, UVec2, Vec2, Vec3, }; -use bevy_math::{Dir3, Isometry3d, Quat, UVec2, Vec2, Vec3}; -use crate::circles::SphereBuilder; -use crate::prelude::{GizmoConfigGroup, Gizmos}; +use crate::{ + circles::SphereBuilder, + prelude::{GizmoConfigGroup, Gizmos}, +}; const DEFAULT_RESOLUTION: u32 = 5; // length used to simulate infinite lines @@ -39,7 +43,10 @@ where Config: GizmoConfigGroup, Clear: 'static + Send + Sync, { - type Output<'a> = () where Self: 'a; + type Output<'a> + = () + where + Self: 'a; fn primitive_3d( &mut self, @@ -60,7 +67,10 @@ where Config: GizmoConfigGroup, Clear: 'static + Send + Sync, { - type Output<'a> = SphereBuilder<'a, 'w, 's, Config, Clear> where Self: 'a; + type Output<'a> + = SphereBuilder<'a, 'w, 's, Config, Clear> + where + Self: 'a; fn primitive_3d( &mut self, @@ -118,7 +128,10 @@ where Config: GizmoConfigGroup, Clear: 'static + Send + Sync, { - type Output<'a> = Plane3dBuilder<'a, 'w, 's, Config, Clear> where Self: 'a; + type Output<'a> + = Plane3dBuilder<'a, 'w, 's, Config, Clear> + where + Self: 'a; fn primitive_3d( &mut self, @@ -167,7 +180,10 @@ where Config: GizmoConfigGroup, Clear: 'static + Send + Sync, { - type Output<'a> = () where Self: 'a; + type Output<'a> + = () + where + Self: 'a; fn primitive_3d( &mut self, @@ -198,7 +214,10 @@ where Config: GizmoConfigGroup, Clear: 'static + Send + Sync, { - type Output<'a> = () where Self: 'a; + type Output<'a> + = () + where + Self: 'a; fn primitive_3d( &mut self, @@ -223,7 +242,10 @@ where Config: GizmoConfigGroup, Clear: 'static + Send + Sync, { - type Output<'a> = () where Self: 'a; + type Output<'a> + = () + where + Self: 'a; fn primitive_3d( &mut self, @@ -246,7 +268,10 @@ where Config: GizmoConfigGroup, Clear: 'static + Send + Sync, { - type Output<'a> = () where Self: 'a; + type Output<'a> + = () + where + Self: 'a; fn primitive_3d( &mut self, @@ -276,7 +301,10 @@ where Config: GizmoConfigGroup, Clear: 'static + Send + Sync, { - type Output<'a> = () where Self: 'a; + type Output<'a> + = () + where + Self: 'a; fn primitive_3d( &mut self, @@ -300,7 +328,10 @@ where Config: GizmoConfigGroup, Clear: 'static + Send + Sync, { - type Output<'a> = () where Self: 'a; + type Output<'a> + = () + where + Self: 'a; fn primitive_3d( &mut self, @@ -390,7 +421,10 @@ where Config: GizmoConfigGroup, Clear: 'static + Send + Sync, { - type Output<'a> = Cylinder3dBuilder<'a, 'w, 's, Config, Clear> where Self: 'a; + type Output<'a> + = Cylinder3dBuilder<'a, 'w, 's, Config, Clear> + where + Self: 'a; fn primitive_3d( &mut self, @@ -473,7 +507,10 @@ where Config: GizmoConfigGroup, Clear: 'static + Send + Sync, { - type Output<'a> = Capsule3dBuilder<'a, 'w, 's, Config, Clear> where Self: 'a; + type Output<'a> + = Capsule3dBuilder<'a, 'w, 's, Config, Clear> + where + Self: 'a; fn primitive_3d( &mut self, @@ -601,7 +638,10 @@ where Config: GizmoConfigGroup, Clear: 'static + Send + Sync, { - type Output<'a> = Cone3dBuilder<'a, 'w, 's, Config, Clear> where Self: 'a; + type Output<'a> + = Cone3dBuilder<'a, 'w, 's, Config, Clear> + where + Self: 'a; fn primitive_3d( &mut self, @@ -700,7 +740,10 @@ where Config: GizmoConfigGroup, Clear: 'static + Send + Sync, { - type Output<'a> = ConicalFrustum3dBuilder<'a, 'w, 's, Config, Clear> where Self: 'a; + type Output<'a> + = ConicalFrustum3dBuilder<'a, 'w, 's, Config, Clear> + where + Self: 'a; fn primitive_3d( &mut self, @@ -801,7 +844,10 @@ where Config: GizmoConfigGroup, Clear: 'static + Send + Sync, { - type Output<'a> = Torus3dBuilder<'a, 'w, 's, Config, Clear> where Self: 'a; + type Output<'a> + = Torus3dBuilder<'a, 'w, 's, Config, Clear> + where + Self: 'a; fn primitive_3d( &mut self, @@ -874,7 +920,10 @@ where // tetrahedron impl<'w, 's, T: GizmoConfigGroup> GizmoPrimitive3d for Gizmos<'w, 's, T> { - type Output<'a> = () where Self: 'a; + type Output<'a> + = () + where + Self: 'a; fn primitive_3d( &mut self, diff --git a/crates/bevy_gltf/src/lib.rs b/crates/bevy_gltf/src/lib.rs index d27a899b76..cb8ead5893 100644 --- a/crates/bevy_gltf/src/lib.rs +++ b/crates/bevy_gltf/src/lib.rs @@ -107,8 +107,7 @@ use bevy_app::prelude::*; use bevy_asset::{Asset, AssetApp, AssetPath, Handle}; use bevy_ecs::{prelude::Component, reflect::ReflectComponent}; use bevy_pbr::StandardMaterial; -use bevy_reflect::std_traits::ReflectDefault; -use bevy_reflect::{Reflect, TypePath}; +use bevy_reflect::{std_traits::ReflectDefault, Reflect, TypePath}; use bevy_render::{ mesh::{skinning::SkinnedMeshInverseBindposes, Mesh, MeshVertexAttribute}, renderer::RenderDevice, diff --git a/crates/bevy_gltf/src/loader.rs b/crates/bevy_gltf/src/loader.rs index d36fc4a39a..e9ca9562da 100644 --- a/crates/bevy_gltf/src/loader.rs +++ b/crates/bevy_gltf/src/loader.rs @@ -14,8 +14,10 @@ use bevy_asset::{ use bevy_color::{Color, LinearRgba}; use bevy_core::Name; use bevy_core_pipeline::prelude::Camera3dBundle; -use bevy_ecs::entity::EntityHashMap; -use bevy_ecs::{entity::Entity, world::World}; +use bevy_ecs::{ + entity::{Entity, EntityHashMap}, + world::World, +}; use bevy_hierarchy::{BuildChildren, ChildBuild, WorldChildBuilder}; use bevy_math::{Affine2, Mat4, Vec3}; use bevy_pbr::{ @@ -43,23 +45,25 @@ use bevy_scene::Scene; #[cfg(not(target_arch = "wasm32"))] use bevy_tasks::IoTaskPool; use bevy_transform::components::Transform; -use bevy_utils::tracing::{error, info_span, warn}; -use bevy_utils::{HashMap, HashSet}; -use gltf::image::Source; +use bevy_utils::{ + tracing::{error, info_span, warn}, + HashMap, HashSet, +}; use gltf::{ accessor::Iter, + image::Source, + json, mesh::{util::ReadIndices, Mode}, texture::{Info, MagFilter, MinFilter, TextureTransform, WrappingMode}, - Material, Node, Primitive, Semantic, + Document, Material, Node, Primitive, Semantic, }; -use gltf::{json, Document}; use serde::{Deserialize, Serialize}; use serde_json::{value, Value}; #[cfg(feature = "bevy_animation")] use smallvec::SmallVec; -use std::io::Error; use std::{ collections::VecDeque, + io::Error, path::{Path, PathBuf}, }; use thiserror::Error; diff --git a/crates/bevy_hierarchy/src/child_builder.rs b/crates/bevy_hierarchy/src/child_builder.rs index 0c9d03ce77..e754ec624d 100644 --- a/crates/bevy_hierarchy/src/child_builder.rs +++ b/crates/bevy_hierarchy/src/child_builder.rs @@ -309,7 +309,10 @@ pub trait ChildBuild { } impl ChildBuild for ChildBuilder<'_> { - type SpawnOutput<'a> = EntityCommands<'a> where Self: 'a; + type SpawnOutput<'a> + = EntityCommands<'a> + where + Self: 'a; fn spawn(&mut self, bundle: impl Bundle) -> EntityCommands { let e = self.commands.spawn(bundle); @@ -535,7 +538,10 @@ pub struct WorldChildBuilder<'w> { } impl ChildBuild for WorldChildBuilder<'_> { - type SpawnOutput<'a> = EntityWorldMut<'a> where Self: 'a; + type SpawnOutput<'a> + = EntityWorldMut<'a> + where + Self: 'a; fn spawn(&mut self, bundle: impl Bundle) -> EntityWorldMut { let entity = self.world.spawn((bundle, Parent(self.parent))).id(); diff --git a/crates/bevy_input/src/button_input.rs b/crates/bevy_input/src/button_input.rs index 3a5d7fd6ae..b122b4c25a 100644 --- a/crates/bevy_input/src/button_input.rs +++ b/crates/bevy_input/src/button_input.rs @@ -153,8 +153,8 @@ use std::hash::Hash; /// It may be preferable to use [`DetectChangesMut::bypass_change_detection`] /// to avoid causing the resource to always be marked as changed. /// -///[`ResMut`]: bevy_ecs::system::ResMut -///[`DetectChangesMut::bypass_change_detection`]: bevy_ecs::change_detection::DetectChangesMut::bypass_change_detection +/// [`ResMut`]: bevy_ecs::system::ResMut +/// [`DetectChangesMut::bypass_change_detection`]: bevy_ecs::change_detection::DetectChangesMut::bypass_change_detection #[derive(Debug, Clone, Resource)] #[cfg_attr(feature = "bevy_reflect", derive(Reflect), reflect(Default, Resource))] pub struct ButtonInput { diff --git a/crates/bevy_input/src/common_conditions.rs b/crates/bevy_input/src/common_conditions.rs index 4a7e4dd7be..a3525f1d99 100644 --- a/crates/bevy_input/src/common_conditions.rs +++ b/crates/bevy_input/src/common_conditions.rs @@ -47,7 +47,6 @@ use std::hash::Hash; /// fn pause_menu() { /// println!("in pause menu"); /// } -/// /// ``` pub fn input_toggle_active( default: bool, diff --git a/crates/bevy_input/src/gamepad.rs b/crates/bevy_input/src/gamepad.rs index 734492df38..d45452cd67 100644 --- a/crates/bevy_input/src/gamepad.rs +++ b/crates/bevy_input/src/gamepad.rs @@ -1,17 +1,16 @@ //! The gamepad input functionality. use crate::{Axis, ButtonInput, ButtonState}; -use bevy_ecs::event::{Event, EventReader, EventWriter}; #[cfg(feature = "bevy_reflect")] use bevy_ecs::reflect::ReflectResource; use bevy_ecs::{ change_detection::DetectChangesMut, + event::{Event, EventReader, EventWriter}, system::{Res, ResMut, Resource}, }; #[cfg(feature = "bevy_reflect")] use bevy_reflect::{std_traits::ReflectDefault, Reflect}; -use bevy_utils::Duration; -use bevy_utils::{tracing::info, HashMap}; +use bevy_utils::{tracing::info, Duration, HashMap}; use thiserror::Error; /// Errors that occur when setting axis settings for gamepad input. diff --git a/crates/bevy_input/src/keyboard.rs b/crates/bevy_input/src/keyboard.rs index 0a9109e46b..223003c85c 100644 --- a/crates/bevy_input/src/keyboard.rs +++ b/crates/bevy_input/src/keyboard.rs @@ -66,9 +66,9 @@ // --------- END OF W3C SHORT NOTICE --------------------------------------------------------------- use crate::{ButtonInput, ButtonState}; -use bevy_ecs::entity::Entity; use bevy_ecs::{ change_detection::DetectChangesMut, + entity::Entity, event::{Event, EventReader}, system::ResMut, }; diff --git a/crates/bevy_input/src/mouse.rs b/crates/bevy_input/src/mouse.rs index e890efccee..2ae9022973 100644 --- a/crates/bevy_input/src/mouse.rs +++ b/crates/bevy_input/src/mouse.rs @@ -1,14 +1,13 @@ //! The mouse input functionality. use crate::{ButtonInput, ButtonState}; -use bevy_ecs::entity::Entity; #[cfg(feature = "bevy_reflect")] use bevy_ecs::reflect::ReflectResource; -use bevy_ecs::system::Resource; use bevy_ecs::{ change_detection::DetectChangesMut, + entity::Entity, event::{Event, EventReader}, - system::ResMut, + system::{ResMut, Resource}, }; use bevy_math::Vec2; #[cfg(feature = "bevy_reflect")] diff --git a/crates/bevy_input/src/touch.rs b/crates/bevy_input/src/touch.rs index 89c749b7e3..a67d1bc2b2 100644 --- a/crates/bevy_input/src/touch.rs +++ b/crates/bevy_input/src/touch.rs @@ -1,8 +1,10 @@ //! The touch input functionality. -use bevy_ecs::entity::Entity; -use bevy_ecs::event::{Event, EventReader}; -use bevy_ecs::system::{ResMut, Resource}; +use bevy_ecs::{ + entity::Entity, + event::{Event, EventReader}, + system::{ResMut, Resource}, +}; use bevy_math::Vec2; #[cfg(feature = "bevy_reflect")] use bevy_reflect::Reflect; diff --git a/crates/bevy_macro_utils/src/label.rs b/crates/bevy_macro_utils/src/label.rs index 43f393739b..130c85d5a6 100644 --- a/crates/bevy_macro_utils/src/label.rs +++ b/crates/bevy_macro_utils/src/label.rs @@ -4,6 +4,7 @@ use std::collections::HashSet; use syn::{spanned::Spanned, Ident}; /// Finds an identifier that will not conflict with the specified set of tokens. +/// /// If the identifier is present in `haystack`, extra characters will be added /// to it until it no longer conflicts with anything. /// diff --git a/crates/bevy_math/src/bounding/bounded3d/extrusion.rs b/crates/bevy_math/src/bounding/bounded3d/extrusion.rs index 631d33790c..2c15d92694 100644 --- a/crates/bevy_math/src/bounding/bounded3d/extrusion.rs +++ b/crates/bevy_math/src/bounding/bounded3d/extrusion.rs @@ -2,12 +2,15 @@ use std::f32::consts::FRAC_PI_2; use glam::{Vec2, Vec3A, Vec3Swizzles}; -use crate::bounding::{BoundingCircle, BoundingVolume}; -use crate::primitives::{ - BoxedPolygon, BoxedPolyline2d, Capsule2d, Cuboid, Cylinder, Ellipse, Extrusion, Line2d, - Polygon, Polyline2d, Primitive2d, Rectangle, RegularPolygon, Segment2d, Triangle2d, +use crate::{ + bounding::{BoundingCircle, BoundingVolume}, + ops, + primitives::{ + BoxedPolygon, BoxedPolyline2d, Capsule2d, Cuboid, Cylinder, Ellipse, Extrusion, Line2d, + Polygon, Polyline2d, Primitive2d, Rectangle, RegularPolygon, Segment2d, Triangle2d, + }, + Isometry2d, Isometry3d, Quat, Rot2, }; -use crate::{ops, Isometry2d, Isometry3d, Quat, Rot2}; use crate::{bounding::Bounded2d, primitives::Circle}; diff --git a/crates/bevy_math/src/common_traits.rs b/crates/bevy_math/src/common_traits.rs index 525d8e4035..481950338f 100644 --- a/crates/bevy_math/src/common_traits.rs +++ b/crates/bevy_math/src/common_traits.rs @@ -1,8 +1,10 @@ //! This module contains abstract mathematical traits shared by types used in `bevy_math`. use crate::{ops, Dir2, Dir3, Dir3A, Quat, Rot2, Vec2, Vec3, Vec3A, Vec4}; -use std::fmt::Debug; -use std::ops::{Add, Div, Mul, Neg, Sub}; +use std::{ + fmt::Debug, + ops::{Add, Div, Mul, Neg, Sub}, +}; /// A type that supports the mathematical operations of a real vector space, irrespective of dimension. /// In particular, this means that the implementing type supports: diff --git a/crates/bevy_math/src/curve/mod.rs b/crates/bevy_math/src/curve/mod.rs index dfadf3db4b..3dfb9284ad 100644 --- a/crates/bevy_math/src/curve/mod.rs +++ b/crates/bevy_math/src/curve/mod.rs @@ -18,6 +18,7 @@ use thiserror::Error; use bevy_reflect::Reflect; /// A trait for a type that can represent values of type `T` parametrized over a fixed interval. +/// /// Typical examples of this are actual geometric curves where `T: VectorSpace`, but other kinds /// of output data can be represented as well. pub trait Curve { diff --git a/crates/bevy_math/src/ops.rs b/crates/bevy_math/src/ops.rs index cee52df323..2e9c3a0ca4 100644 --- a/crates/bevy_math/src/ops.rs +++ b/crates/bevy_math/src/ops.rs @@ -290,6 +290,7 @@ mod libm_ops { } /// Compute the distance between the origin and a point `(x, y)` on the Euclidean plane. + /// /// Equivalently, compute the length of the hypotenuse of a right-angle triangle with other sides having length `x.abs()` and `y.abs()`. /// /// Precision is specified when the `libm` feature is enabled. diff --git a/crates/bevy_math/src/rotation2d.rs b/crates/bevy_math/src/rotation2d.rs index 02f6d34117..51290241ba 100644 --- a/crates/bevy_math/src/rotation2d.rs +++ b/crates/bevy_math/src/rotation2d.rs @@ -120,7 +120,6 @@ impl Rot2 { /// /// let rot3 = Rot2::radians(PI); /// assert_relative_eq!(rot1 * rot1, rot3); - /// /// ``` #[inline] pub fn radians(radians: f32) -> Self { @@ -146,7 +145,6 @@ impl Rot2 { /// /// let rot3 = Rot2::degrees(180.0); /// assert_relative_eq!(rot1 * rot1, rot3); - /// /// ``` #[inline] pub fn degrees(degrees: f32) -> Self { @@ -171,7 +169,6 @@ impl Rot2 { /// /// let rot3 = Rot2::turn_fraction(0.5); /// assert_relative_eq!(rot1 * rot1, rot3); - /// /// ``` #[inline] pub fn turn_fraction(fraction: f32) -> Self { diff --git a/crates/bevy_mikktspace/tests/regression_test.rs b/crates/bevy_mikktspace/tests/regression_test.rs index 42177cbc34..6ddee5e418 100644 --- a/crates/bevy_mikktspace/tests/regression_test.rs +++ b/crates/bevy_mikktspace/tests/regression_test.rs @@ -1,11 +1,12 @@ #![allow( clippy::bool_assert_comparison, - clippy::useless_conversion, - clippy::redundant_else, - clippy::match_same_arms, - clippy::semicolon_if_nothing_returned, clippy::explicit_iter_loop, - clippy::map_flatten + clippy::map_flatten, + clippy::match_same_arms, + clippy::redundant_else, + clippy::semicolon_if_nothing_returned, + clippy::useless_conversion, + missing_docs )] use bevy_mikktspace::{generate_tangents, Geometry}; diff --git a/crates/bevy_pbr/src/bundle.rs b/crates/bevy_pbr/src/bundle.rs index 52c7c64384..7c6b9fef9f 100644 --- a/crates/bevy_pbr/src/bundle.rs +++ b/crates/bevy_pbr/src/bundle.rs @@ -4,10 +4,13 @@ use crate::{ }; use bevy_asset::Handle; use bevy_derive::{Deref, DerefMut}; -use bevy_ecs::entity::{Entity, EntityHashMap}; -use bevy_ecs::{bundle::Bundle, component::Component, reflect::ReflectComponent}; -use bevy_reflect::std_traits::ReflectDefault; -use bevy_reflect::Reflect; +use bevy_ecs::{ + bundle::Bundle, + component::Component, + entity::{Entity, EntityHashMap}, + reflect::ReflectComponent, +}; +use bevy_reflect::{std_traits::ReflectDefault, Reflect}; use bevy_render::{ mesh::Mesh, primitives::{CascadesFrusta, CubemapFrusta, Frustum}, @@ -48,6 +51,7 @@ impl Default for MaterialMeshBundle { } /// Collection of mesh entities visible for 3D lighting. +/// /// This component contains all mesh entities visible from the current light view. /// The collection is updated automatically by [`crate::SimulationLightSystems`]. #[derive(Component, Clone, Debug, Default, Reflect, Deref, DerefMut)] diff --git a/crates/bevy_pbr/src/cluster/assign.rs b/crates/bevy_pbr/src/cluster/assign.rs index 8e358a29b9..1f3f1bc52d 100644 --- a/crates/bevy_pbr/src/cluster/assign.rs +++ b/crates/bevy_pbr/src/cluster/assign.rs @@ -792,6 +792,7 @@ fn ndc_position_to_cluster( } /// Calculate bounds for the clusterable object using a view space aabb. +/// /// Returns a `(Vec3, Vec3)` containing minimum and maximum with /// `X` and `Y` in normalized device coordinates with range `[-1, 1]` /// `Z` in view space, with range `[-inf, -f32::MIN_POSITIVE]` diff --git a/crates/bevy_pbr/src/deferred/mod.rs b/crates/bevy_pbr/src/deferred/mod.rs index 10d8a57962..fe1a652d24 100644 --- a/crates/bevy_pbr/src/deferred/mod.rs +++ b/crates/bevy_pbr/src/deferred/mod.rs @@ -20,8 +20,7 @@ use bevy_render::{ ComponentUniforms, ExtractComponent, ExtractComponentPlugin, UniformComponentPlugin, }, render_graph::{NodeRunError, RenderGraphApp, RenderGraphContext, ViewNode, ViewNodeRunner}, - render_resource::binding_types::uniform_buffer, - render_resource::*, + render_resource::{binding_types::uniform_buffer, *}, renderer::{RenderContext, RenderDevice}, texture::BevyDefault, view::{ExtractedView, ViewTarget, ViewUniformOffset}, @@ -40,6 +39,7 @@ pub const DEFERRED_LIGHTING_SHADER_HANDLE: Handle = pub const DEFAULT_PBR_DEFERRED_LIGHTING_PASS_ID: u8 = 1; /// Component with a `depth_id` for specifying which corresponding materials should be rendered by this specific PBR deferred lighting pass. +/// /// Will be automatically added to entities with the [`DeferredPrepass`] component that don't already have a [`PbrDeferredLightingDepthId`]. #[derive(Component, Clone, Copy, ExtractComponent, ShaderType)] pub struct PbrDeferredLightingDepthId { diff --git a/crates/bevy_pbr/src/extended_material.rs b/crates/bevy_pbr/src/extended_material.rs index 81b3c6ebbb..cef4784ad2 100644 --- a/crates/bevy_pbr/src/extended_material.rs +++ b/crates/bevy_pbr/src/extended_material.rs @@ -25,6 +25,7 @@ pub struct MaterialExtensionKey { } /// A subset of the `Material` trait for defining extensions to a base `Material`, such as the builtin `StandardMaterial`. +/// /// A user type implementing the trait should be used as the `E` generic param in an `ExtendedMaterial` struct. pub trait MaterialExtension: Asset + AsBindGroup + Clone + Sized { /// Returns this material's vertex shader. If [`ShaderRef::Default`] is returned, the base material mesh vertex shader diff --git a/crates/bevy_pbr/src/light/mod.rs b/crates/bevy_pbr/src/light/mod.rs index 28b4630411..8bf10e3475 100644 --- a/crates/bevy_pbr/src/light/mod.rs +++ b/crates/bevy_pbr/src/light/mod.rs @@ -1,7 +1,6 @@ use std::ops::DerefMut; -use bevy_ecs::entity::EntityHashMap; -use bevy_ecs::prelude::*; +use bevy_ecs::{entity::EntityHashMap, prelude::*}; use bevy_math::{ops, Mat4, Vec3A, Vec4}; use bevy_reflect::prelude::*; use bevy_render::{ @@ -370,6 +369,7 @@ pub fn build_directional_light_cascades( } /// Returns a [`Cascade`] for the frustum defined by `frustum_corners`. +/// /// The corner vertices should be specified in the following order: /// first the bottom right, top right, top left, bottom left for the near plane, then similar for the far plane. fn calculate_cascade( diff --git a/crates/bevy_pbr/src/light/spot_light.rs b/crates/bevy_pbr/src/light/spot_light.rs index f2e595fbf8..88c69995cf 100644 --- a/crates/bevy_pbr/src/light/spot_light.rs +++ b/crates/bevy_pbr/src/light/spot_light.rs @@ -1,6 +1,7 @@ use super::*; /// A light that emits light in a given direction from a central point. +/// /// Behaves like a point light in a perfectly absorbent housing that /// shines light only in a given direction. The direction is taken from /// the transform, and can be specified with [`Transform::looking_at`](Transform::looking_at). diff --git a/crates/bevy_pbr/src/light_probe/environment_map.rs b/crates/bevy_pbr/src/light_probe/environment_map.rs index a9be284fba..f60a8b34f3 100644 --- a/crates/bevy_pbr/src/light_probe/environment_map.rs +++ b/crates/bevy_pbr/src/light_probe/environment_map.rs @@ -52,8 +52,7 @@ use bevy_ecs::{ system::lifetimeless::Read, }; use bevy_math::Quat; -use bevy_reflect::std_traits::ReflectDefault; -use bevy_reflect::Reflect; +use bevy_reflect::{std_traits::ReflectDefault, Reflect}; use bevy_render::{ extract_instances::ExtractInstance, prelude::SpatialBundle, @@ -67,8 +66,7 @@ use bevy_render::{ texture::{FallbackImage, GpuImage, Image}, }; -use std::num::NonZero; -use std::ops::Deref; +use std::{num::NonZero, ops::Deref}; use crate::{ add_cubemap_texture_view, binding_arrays_are_usable, EnvironmentMapUniform, LightProbe, diff --git a/crates/bevy_pbr/src/light_probe/irradiance_volume.rs b/crates/bevy_pbr/src/light_probe/irradiance_volume.rs index 34f9f902a6..8a4e4c2402 100644 --- a/crates/bevy_pbr/src/light_probe/irradiance_volume.rs +++ b/crates/bevy_pbr/src/light_probe/irradiance_volume.rs @@ -145,8 +145,7 @@ use bevy_render::{ use std::{num::NonZero, ops::Deref}; use bevy_asset::{AssetId, Handle}; -use bevy_reflect::std_traits::ReflectDefault; -use bevy_reflect::Reflect; +use bevy_reflect::{std_traits::ReflectDefault, Reflect}; use crate::{ add_cubemap_texture_view, binding_arrays_are_usable, RenderViewLightProbes, diff --git a/crates/bevy_pbr/src/light_probe/mod.rs b/crates/bevy_pbr/src/light_probe/mod.rs index 7d84a28b19..0a35aee1a2 100644 --- a/crates/bevy_pbr/src/light_probe/mod.rs +++ b/crates/bevy_pbr/src/light_probe/mod.rs @@ -28,8 +28,7 @@ use bevy_render::{ use bevy_transform::{components::Transform, prelude::GlobalTransform}; use bevy_utils::{tracing::error, HashMap}; -use std::hash::Hash; -use std::ops::Deref; +use std::{hash::Hash, ops::Deref}; use crate::{ irradiance_volume::IRRADIANCE_VOLUME_SHADER_HANDLE, @@ -368,6 +367,7 @@ impl Plugin for LightProbePlugin { } /// Extracts [`EnvironmentMapLight`] from views and creates [`EnvironmentMapUniform`] for them. +/// /// Compared to the `ExtractComponentPlugin`, this implementation will create a default instance /// if one does not already exist. fn gather_environment_map_uniform( diff --git a/crates/bevy_pbr/src/lightmap/mod.rs b/crates/bevy_pbr/src/lightmap/mod.rs index 913f86a812..d1fd1cc143 100644 --- a/crates/bevy_pbr/src/lightmap/mod.rs +++ b/crates/bevy_pbr/src/lightmap/mod.rs @@ -30,21 +30,22 @@ use bevy_app::{App, Plugin}; use bevy_asset::{load_internal_asset, AssetId, Handle}; -use bevy_ecs::entity::EntityHashMap; use bevy_ecs::{ component::Component, - entity::Entity, + entity::{Entity, EntityHashMap}, reflect::ReflectComponent, schedule::IntoSystemConfigs, system::{Query, Res, ResMut, Resource}, }; use bevy_math::{uvec2, vec4, Rect, UVec2}; use bevy_reflect::{std_traits::ReflectDefault, Reflect}; -use bevy_render::mesh::RenderMesh; -use bevy_render::texture::GpuImage; use bevy_render::{ - mesh::Mesh, render_asset::RenderAssets, render_resource::Shader, texture::Image, - view::ViewVisibility, Extract, ExtractSchedule, RenderApp, + mesh::{Mesh, RenderMesh}, + render_asset::RenderAssets, + render_resource::Shader, + texture::{GpuImage, Image}, + view::ViewVisibility, + Extract, ExtractSchedule, RenderApp, }; use bevy_utils::HashSet; diff --git a/crates/bevy_pbr/src/material.rs b/crates/bevy_pbr/src/material.rs index 8bf6ae254d..c4edd1101c 100644 --- a/crates/bevy_pbr/src/material.rs +++ b/crates/bevy_pbr/src/material.rs @@ -20,8 +20,7 @@ use bevy_ecs::{ prelude::*, system::{lifetimeless::SRes, SystemParamItem}, }; -use bevy_reflect::std_traits::ReflectDefault; -use bevy_reflect::Reflect; +use bevy_reflect::{std_traits::ReflectDefault, Reflect}; use bevy_render::{ camera::TemporalJitter, extract_instances::{ExtractInstancesPlugin, ExtractedInstances}, @@ -34,9 +33,12 @@ use bevy_render::{ view::{ExtractedView, Msaa, RenderVisibilityRanges, VisibleEntities, WithMesh}, }; use bevy_utils::tracing::error; -use std::marker::PhantomData; -use std::sync::atomic::{AtomicU32, Ordering}; -use std::{hash::Hash, num::NonZero}; +use std::{ + hash::Hash, + marker::PhantomData, + num::NonZero, + sync::atomic::{AtomicU32, Ordering}, +}; use self::{irradiance_volume::IrradianceVolume, prelude::EnvironmentMapLight}; diff --git a/crates/bevy_pbr/src/meshlet/from_mesh.rs b/crates/bevy_pbr/src/meshlet/from_mesh.rs index 660a5bdeea..aa132e1441 100644 --- a/crates/bevy_pbr/src/meshlet/from_mesh.rs +++ b/crates/bevy_pbr/src/meshlet/from_mesh.rs @@ -281,7 +281,7 @@ fn simplify_meshlet_group( vertices, group_indices.len() / 2, f32::MAX, - SimplifyOptions::LockBorder | SimplifyOptions::Sparse | SimplifyOptions::ErrorAbsolute, // TODO: Specify manual vertex locks instead of meshopt's overly-strict locks + SimplifyOptions::LockBorder | SimplifyOptions::Sparse | SimplifyOptions::ErrorAbsolute, /* TODO: Specify manual vertex locks instead of meshopt's overly-strict locks */ Some(&mut error), ); diff --git a/crates/bevy_pbr/src/pbr_material.rs b/crates/bevy_pbr/src/pbr_material.rs index 9e4a1c920b..830e5e284f 100644 --- a/crates/bevy_pbr/src/pbr_material.rs +++ b/crates/bevy_pbr/src/pbr_material.rs @@ -7,10 +7,10 @@ use bevy_render::{ }; use bitflags::bitflags; -use crate::deferred::DEFAULT_PBR_DEFERRED_LIGHTING_PASS_ID; -use crate::*; +use crate::{deferred::DEFAULT_PBR_DEFERRED_LIGHTING_PASS_ID, *}; /// An enum to define which UV attribute to use for a texture. +/// /// It is used for every texture in the [`StandardMaterial`]. /// It only supports two UV attributes, [`bevy_render::mesh::Mesh::ATTRIBUTE_UV_0`] and /// [`bevy_render::mesh::Mesh::ATTRIBUTE_UV_1`]. @@ -128,7 +128,6 @@ pub struct StandardMaterial { /// /// 0.089 is the minimum floating point value that won't be rounded down to 0 in the /// calculations used. - // // Technically for 32-bit floats, 0.045 could be used. // See pub perceptual_roughness: f32, diff --git a/crates/bevy_pbr/src/prepass/mod.rs b/crates/bevy_pbr/src/prepass/mod.rs index 859a862406..5ac73690b3 100644 --- a/crates/bevy_pbr/src/prepass/mod.rs +++ b/crates/bevy_pbr/src/prepass/mod.rs @@ -1,13 +1,16 @@ mod prepass_bindings; -use bevy_render::mesh::{MeshVertexBufferLayoutRef, RenderMesh}; -use bevy_render::render_resource::binding_types::uniform_buffer; -use bevy_render::view::WithMesh; +use bevy_render::{ + mesh::{MeshVertexBufferLayoutRef, RenderMesh}, + render_resource::binding_types::uniform_buffer, + view::WithMesh, +}; pub use prepass_bindings::*; use bevy_asset::{load_internal_asset, AssetServer}; -use bevy_core_pipeline::{core_3d::CORE_3D_DEPTH_FORMAT, prelude::Camera3d}; -use bevy_core_pipeline::{deferred::*, prepass::*}; +use bevy_core_pipeline::{ + core_3d::CORE_3D_DEPTH_FORMAT, deferred::*, prelude::Camera3d, prepass::*, +}; use bevy_ecs::{ prelude::*, system::{ diff --git a/crates/bevy_pbr/src/render/gpu_preprocess.rs b/crates/bevy_pbr/src/render/gpu_preprocess.rs index 38650d2808..502b2e7210 100644 --- a/crates/bevy_pbr/src/render/gpu_preprocess.rs +++ b/crates/bevy_pbr/src/render/gpu_preprocess.rs @@ -294,11 +294,11 @@ impl FromWorld for PreprocessPipelines { let gpu_culling_bind_group_layout_entries = preprocess_direct_bind_group_layout_entries() .extend_sequential(( // `indirect_parameters` - storage_buffer::(/*has_dynamic_offset=*/ false), + storage_buffer::(/* has_dynamic_offset= */ false), // `mesh_culling_data` - storage_buffer_read_only::(/*has_dynamic_offset=*/ false), + storage_buffer_read_only::(/* has_dynamic_offset= */ false), // `view` - uniform_buffer::(/*has_dynamic_offset=*/ true), + uniform_buffer::(/* has_dynamic_offset= */ true), )); let direct_bind_group_layout = render_device.create_bind_group_layout( diff --git a/crates/bevy_pbr/src/render/light.rs b/crates/bevy_pbr/src/render/light.rs index 86fd2151ce..aa8fd87f97 100644 --- a/crates/bevy_pbr/src/render/light.rs +++ b/crates/bevy_pbr/src/render/light.rs @@ -1,9 +1,11 @@ use bevy_asset::UntypedAssetId; use bevy_color::ColorToComponents; use bevy_core_pipeline::core_3d::{Camera3d, CORE_3D_DEPTH_FORMAT}; -use bevy_ecs::entity::EntityHashSet; -use bevy_ecs::prelude::*; -use bevy_ecs::{entity::EntityHashMap, system::lifetimeless::Read}; +use bevy_ecs::{ + entity::{EntityHashMap, EntityHashSet}, + prelude::*, + system::lifetimeless::Read, +}; use bevy_math::{ops, Mat4, UVec4, Vec2, Vec3, Vec3Swizzles, Vec4, Vec4Swizzles}; use bevy_render::{ diagnostic::RecordDiagnostics, @@ -19,10 +21,12 @@ use bevy_render::{ Extract, }; use bevy_transform::{components::GlobalTransform, prelude::Transform}; -use bevy_utils::prelude::default; #[cfg(feature = "trace")] use bevy_utils::tracing::info_span; -use bevy_utils::tracing::{error, warn}; +use bevy_utils::{ + prelude::default, + tracing::{error, warn}, +}; use std::{hash::Hash, ops::Range}; use crate::*; @@ -118,7 +122,7 @@ pub struct GpuLights { spot_light_shadowmap_offset: i32, } -//NOTE: When running bevy on Adreno GPU chipsets in WebGL, any value above 1 will result in a crash +// NOTE: When running bevy on Adreno GPU chipsets in WebGL, any value above 1 will result in a crash // when loading the wgsl "pbr_functions.wgsl" in the function apply_fog. #[cfg(all(feature = "webgl", target_arch = "wasm32", not(feature = "webgpu")))] pub const MAX_DIRECTIONAL_LIGHTS: usize = 1; diff --git a/crates/bevy_pbr/src/render/mesh.rs b/crates/bevy_pbr/src/render/mesh.rs index 007ed983e5..27d543a061 100644 --- a/crates/bevy_pbr/src/render/mesh.rs +++ b/crates/bevy_pbr/src/render/mesh.rs @@ -8,8 +8,8 @@ use bevy_core_pipeline::{ prepass::MotionVectorPrepass, }; use bevy_derive::{Deref, DerefMut}; -use bevy_ecs::entity::EntityHashMap; use bevy_ecs::{ + entity::EntityHashMap, prelude::*, query::ROQueryItem, system::{lifetimeless::*, SystemParamItem, SystemState}, @@ -40,19 +40,25 @@ use bevy_render::{ Extract, }; use bevy_transform::components::GlobalTransform; -use bevy_utils::{tracing::error, tracing::warn, Entry, HashMap, Parallel}; +use bevy_utils::{ + tracing::{error, warn}, + Entry, HashMap, Parallel, +}; use bytemuck::{Pod, Zeroable}; use nonmax::{NonMaxU16, NonMaxU32}; use static_assertions::const_assert_eq; -use crate::render::{ - morph::{ - extract_morphs, no_automatic_morph_batching, prepare_morphs, MorphIndices, MorphUniforms, +use crate::{ + render::{ + morph::{ + extract_morphs, no_automatic_morph_batching, prepare_morphs, MorphIndices, + MorphUniforms, + }, + skin::no_automatic_skin_batching, }, - skin::no_automatic_skin_batching, + *, }; -use crate::*; use self::irradiance_volume::IRRADIANCE_VOLUMES_ARE_USABLE; diff --git a/crates/bevy_pbr/src/render/morph.rs b/crates/bevy_pbr/src/render/morph.rs index 2f28fbf588..259481e379 100644 --- a/crates/bevy_pbr/src/render/morph.rs +++ b/crates/bevy_pbr/src/render/morph.rs @@ -1,7 +1,6 @@ use std::{iter, mem}; -use bevy_ecs::entity::EntityHashMap; -use bevy_ecs::prelude::*; +use bevy_ecs::{entity::EntityHashMap, prelude::*}; use bevy_render::{ batching::NoAutomaticBatching, mesh::morph::{MeshMorphWeights, MAX_MORPH_WEIGHTS}, diff --git a/crates/bevy_pbr/src/render/skin.rs b/crates/bevy_pbr/src/render/skin.rs index 6d6f974b76..eea4c7a843 100644 --- a/crates/bevy_pbr/src/render/skin.rs +++ b/crates/bevy_pbr/src/render/skin.rs @@ -1,8 +1,7 @@ use std::mem::{self, size_of}; use bevy_asset::Assets; -use bevy_ecs::entity::EntityHashMap; -use bevy_ecs::prelude::*; +use bevy_ecs::{entity::EntityHashMap, prelude::*}; use bevy_math::Mat4; use bevy_render::{ batching::NoAutomaticBatching, diff --git a/crates/bevy_pbr/src/ssao/mod.rs b/crates/bevy_pbr/src/ssao/mod.rs index 249a2267b7..eff2ec733b 100644 --- a/crates/bevy_pbr/src/ssao/mod.rs +++ b/crates/bevy_pbr/src/ssao/mod.rs @@ -14,8 +14,7 @@ use bevy_ecs::{ system::{Commands, Query, Res, ResMut, Resource}, world::{FromWorld, World}, }; -use bevy_reflect::std_traits::ReflectDefault; -use bevy_reflect::Reflect; +use bevy_reflect::{std_traits::ReflectDefault, Reflect}; use bevy_render::{ camera::{ExtractedCamera, TemporalJitter}, extract_component::ExtractComponent, diff --git a/crates/bevy_pbr/src/volumetric_fog/mod.rs b/crates/bevy_pbr/src/volumetric_fog/mod.rs index cbf735b592..8a45fdc4b0 100644 --- a/crates/bevy_pbr/src/volumetric_fog/mod.rs +++ b/crates/bevy_pbr/src/volumetric_fog/mod.rs @@ -44,8 +44,7 @@ use bevy_math::{ primitives::{Cuboid, Plane3d}, Vec2, Vec3, }; -use bevy_reflect::std_traits::ReflectDefault; -use bevy_reflect::Reflect; +use bevy_reflect::{std_traits::ReflectDefault, Reflect}; use bevy_render::{ mesh::{Mesh, Meshable}, render_graph::{RenderGraphApp, ViewNodeRunner}, diff --git a/crates/bevy_pbr/src/wireframe.rs b/crates/bevy_pbr/src/wireframe.rs index 0b2c3bf47e..86e8bd49e9 100644 --- a/crates/bevy_pbr/src/wireframe.rs +++ b/crates/bevy_pbr/src/wireframe.rs @@ -60,11 +60,11 @@ impl Plugin for WireframePlugin { pub struct Wireframe; /// Sets the color of the [`Wireframe`] of the entity it is attached to. +/// /// If this component is present but there's no [`Wireframe`] component, /// it will still affect the color of the wireframe when [`WireframeConfig::global`] is set to true. /// /// This overrides the [`WireframeConfig::default_color`]. -// // TODO: consider caching materials based on this color. // This could blow up in size if people use random colored wireframes for each mesh. // It will also be important to remove unused materials from the cache. diff --git a/crates/bevy_picking/src/input.rs b/crates/bevy_picking/src/input.rs index bef8b57c47..0238f9d76b 100644 --- a/crates/bevy_picking/src/input.rs +++ b/crates/bevy_picking/src/input.rs @@ -14,8 +14,11 @@ use bevy_app::prelude::*; use bevy_ecs::prelude::*; use bevy_hierarchy::DespawnRecursiveExt; -use bevy_input::touch::{TouchInput, TouchPhase}; -use bevy_input::{prelude::*, ButtonState}; +use bevy_input::{ + prelude::*, + touch::{TouchInput, TouchPhase}, + ButtonState, +}; use bevy_math::Vec2; use bevy_reflect::prelude::*; use bevy_render::camera::RenderTarget; diff --git a/crates/bevy_ptr/src/lib.rs b/crates/bevy_ptr/src/lib.rs index f083c6a3b8..bab0cec5fb 100644 --- a/crates/bevy_ptr/src/lib.rs +++ b/crates/bevy_ptr/src/lib.rs @@ -179,6 +179,7 @@ pub struct Ptr<'a, A: IsAligned = Aligned>(NonNull, PhantomData<(&'a u8, A)> pub struct PtrMut<'a, A: IsAligned = Aligned>(NonNull, PhantomData<(&'a mut u8, A)>); /// Type-erased Box-like pointer to some unknown type chosen when constructing this type. +/// /// Conceptually represents ownership of whatever data is being pointed to and so is /// responsible for calling its `Drop` impl. This pointer is _not_ responsible for freeing /// the memory pointed to by this pointer as it may be pointing to an element in a `Vec` or diff --git a/crates/bevy_reflect/derive/src/attribute_parser.rs b/crates/bevy_reflect/derive/src/attribute_parser.rs index 8696fee265..52c5172ffd 100644 --- a/crates/bevy_reflect/derive/src/attribute_parser.rs +++ b/crates/bevy_reflect/derive/src/attribute_parser.rs @@ -1,5 +1,7 @@ -use syn::parse::{Parse, ParseStream, Peek}; -use syn::punctuated::Punctuated; +use syn::{ + parse::{Parse, ParseStream, Peek}, + punctuated::Punctuated, +}; /// Returns a [`syn::parse::Parser`] which parses a stream of zero or more occurrences of `T` /// separated by punctuation of type `P`, with optional trailing punctuation. diff --git a/crates/bevy_reflect/derive/src/container_attributes.rs b/crates/bevy_reflect/derive/src/container_attributes.rs index 7aa027cb1f..b134c571c0 100644 --- a/crates/bevy_reflect/derive/src/container_attributes.rs +++ b/crates/bevy_reflect/derive/src/container_attributes.rs @@ -5,16 +5,17 @@ //! the derive helper attribute for `Reflect`, which looks like: //! `#[reflect(PartialEq, Default, ...)]`. -use crate::attribute_parser::terminated_parser; -use crate::custom_attributes::CustomAttributes; -use crate::derive_data::ReflectTraitToImpl; +use crate::{ + attribute_parser::terminated_parser, custom_attributes::CustomAttributes, + derive_data::ReflectTraitToImpl, +}; use bevy_macro_utils::fq_std::{FQAny, FQOption}; use proc_macro2::{Ident, Span}; use quote::quote_spanned; -use syn::ext::IdentExt; -use syn::parse::ParseStream; -use syn::spanned::Spanned; -use syn::{parenthesized, token, Expr, LitBool, MetaList, MetaNameValue, Path, Token, WhereClause}; +use syn::{ + ext::IdentExt, parenthesized, parse::ParseStream, spanned::Spanned, token, Expr, LitBool, + MetaList, MetaNameValue, Path, Token, WhereClause, +}; mod kw { syn::custom_keyword!(from_reflect); @@ -178,7 +179,6 @@ impl TypePathAttrs { /// ``` /// /// > __Note:__ Registering a custom function only works for special traits. -/// #[derive(Default, Clone)] pub(crate) struct ContainerAttributes { debug: TraitImpl, diff --git a/crates/bevy_reflect/derive/src/custom_attributes.rs b/crates/bevy_reflect/derive/src/custom_attributes.rs index 68bb7d1843..f12b6d7c12 100644 --- a/crates/bevy_reflect/derive/src/custom_attributes.rs +++ b/crates/bevy_reflect/derive/src/custom_attributes.rs @@ -1,7 +1,6 @@ use proc_macro2::TokenStream; use quote::quote; -use syn::parse::ParseStream; -use syn::{Expr, Path, Token}; +use syn::{parse::ParseStream, Expr, Path, Token}; #[derive(Default, Clone)] pub(crate) struct CustomAttributes { diff --git a/crates/bevy_reflect/derive/src/derive_data.rs b/crates/bevy_reflect/derive/src/derive_data.rs index 5c2e99db5b..4e04d6670d 100644 --- a/crates/bevy_reflect/derive/src/derive_data.rs +++ b/crates/bevy_reflect/derive/src/derive_data.rs @@ -1,23 +1,24 @@ use core::fmt; use proc_macro2::Span; -use crate::container_attributes::{ContainerAttributes, FromReflectAttrs, TypePathAttrs}; -use crate::field_attributes::FieldAttributes; -use crate::result_sifter::ResultSifter; -use crate::string_expr::StringExpr; -use crate::type_path::parse_path_no_leading_colon; -use crate::where_clause_options::WhereClauseOptions; +use crate::{ + container_attributes::{ContainerAttributes, FromReflectAttrs, TypePathAttrs}, + field_attributes::FieldAttributes, + result_sifter::ResultSifter, + string_expr::StringExpr, + type_path::parse_path_no_leading_colon, + where_clause_options::WhereClauseOptions, +}; use quote::{quote, ToTokens}; use syn::token::Comma; -use crate::remote::RemoteType; -use crate::serialization::SerializationDataDef; -use crate::{REFLECT_ATTRIBUTE_NAME, TYPE_NAME_ATTRIBUTE_NAME, TYPE_PATH_ATTRIBUTE_NAME}; -use syn::punctuated::Punctuated; -use syn::spanned::Spanned; +use crate::{ + remote::RemoteType, serialization::SerializationDataDef, REFLECT_ATTRIBUTE_NAME, + TYPE_NAME_ATTRIBUTE_NAME, TYPE_PATH_ATTRIBUTE_NAME, +}; use syn::{ - parse_str, Data, DeriveInput, Field, Fields, GenericParam, Generics, Ident, LitStr, Meta, Path, - PathSegment, Type, TypeParam, Variant, + parse_str, punctuated::Punctuated, spanned::Spanned, Data, DeriveInput, Field, Fields, + GenericParam, Generics, Ident, LitStr, Meta, Path, PathSegment, Type, TypeParam, Variant, }; pub(crate) enum ReflectDerive<'a> { @@ -866,7 +867,6 @@ impl<'a> EnumVariant<'a> { /// let module_path = type_path.module_path(); /// # Ok::<(), syn::Error>(()) /// ``` -/// pub(crate) enum ReflectTypePath<'a> { /// Types without a crate/module that can be named from any scope (e.g. `bool`). Primitive(&'a Ident), diff --git a/crates/bevy_reflect/derive/src/enum_utility.rs b/crates/bevy_reflect/derive/src/enum_utility.rs index 766e94b859..b370d36703 100644 --- a/crates/bevy_reflect/derive/src/enum_utility.rs +++ b/crates/bevy_reflect/derive/src/enum_utility.rs @@ -1,6 +1,8 @@ -use crate::derive_data::StructField; -use crate::field_attributes::DefaultBehavior; -use crate::{derive_data::ReflectEnum, ident::ident_or_index}; +use crate::{ + derive_data::{ReflectEnum, StructField}, + field_attributes::DefaultBehavior, + ident::ident_or_index, +}; use bevy_macro_utils::fq_std::{FQDefault, FQOption}; use proc_macro2::{Ident, TokenStream}; use quote::{format_ident, quote}; diff --git a/crates/bevy_reflect/derive/src/field_attributes.rs b/crates/bevy_reflect/derive/src/field_attributes.rs index a0ef12ef8f..6cddb50e61 100644 --- a/crates/bevy_reflect/derive/src/field_attributes.rs +++ b/crates/bevy_reflect/derive/src/field_attributes.rs @@ -4,12 +4,12 @@ //! as opposed to an entire struct or enum. An example of such an attribute is //! the derive helper attribute for `Reflect`, which looks like: `#[reflect(ignore)]`. -use crate::attribute_parser::terminated_parser; -use crate::custom_attributes::CustomAttributes; -use crate::REFLECT_ATTRIBUTE_NAME; +use crate::{ + attribute_parser::terminated_parser, custom_attributes::CustomAttributes, + REFLECT_ATTRIBUTE_NAME, +}; use quote::ToTokens; -use syn::parse::ParseStream; -use syn::{Attribute, LitStr, Meta, Token, Type}; +use syn::{parse::ParseStream, Attribute, LitStr, Meta, Token, Type}; mod kw { syn::custom_keyword!(ignore); diff --git a/crates/bevy_reflect/derive/src/from_reflect.rs b/crates/bevy_reflect/derive/src/from_reflect.rs index 026fb33dba..d994cbd2f7 100644 --- a/crates/bevy_reflect/derive/src/from_reflect.rs +++ b/crates/bevy_reflect/derive/src/from_reflect.rs @@ -1,10 +1,12 @@ -use crate::container_attributes::REFLECT_DEFAULT; -use crate::derive_data::ReflectEnum; -use crate::enum_utility::{EnumVariantOutputData, FromReflectVariantBuilder, VariantBuilder}; -use crate::field_attributes::DefaultBehavior; -use crate::ident::ident_or_index; -use crate::where_clause_options::WhereClauseOptions; -use crate::{ReflectMeta, ReflectStruct}; +use crate::{ + container_attributes::REFLECT_DEFAULT, + derive_data::ReflectEnum, + enum_utility::{EnumVariantOutputData, FromReflectVariantBuilder, VariantBuilder}, + field_attributes::DefaultBehavior, + ident::ident_or_index, + where_clause_options::WhereClauseOptions, + ReflectMeta, ReflectStruct, +}; use bevy_macro_utils::fq_std::{FQClone, FQDefault, FQOption}; use proc_macro2::Span; use quote::{quote, ToTokens}; diff --git a/crates/bevy_reflect/derive/src/impls/assertions.rs b/crates/bevy_reflect/derive/src/impls/assertions.rs index 06d835e6cf..22a2c4f5a3 100644 --- a/crates/bevy_reflect/derive/src/impls/assertions.rs +++ b/crates/bevy_reflect/derive/src/impls/assertions.rs @@ -1,5 +1,4 @@ -use crate::derive_data::ReflectDerive; -use crate::remote::generate_remote_assertions; +use crate::{derive_data::ReflectDerive, remote::generate_remote_assertions}; use quote::quote; /// Generates an anonymous block containing compile-time assertions. diff --git a/crates/bevy_reflect/derive/src/impls/enums.rs b/crates/bevy_reflect/derive/src/impls/enums.rs index 15d5c01ffa..c4791ca32b 100644 --- a/crates/bevy_reflect/derive/src/impls/enums.rs +++ b/crates/bevy_reflect/derive/src/impls/enums.rs @@ -1,6 +1,8 @@ -use crate::derive_data::{EnumVariantFields, ReflectEnum, StructField}; -use crate::enum_utility::{EnumVariantOutputData, TryApplyVariantBuilder, VariantBuilder}; -use crate::impls::{common_partial_reflect_methods, impl_full_reflect, impl_type_path, impl_typed}; +use crate::{ + derive_data::{EnumVariantFields, ReflectEnum, StructField}, + enum_utility::{EnumVariantOutputData, TryApplyVariantBuilder, VariantBuilder}, + impls::{common_partial_reflect_methods, impl_full_reflect, impl_type_path, impl_typed}, +}; use bevy_macro_utils::fq_std::{FQBox, FQOption, FQResult}; use proc_macro2::{Ident, Span}; use quote::quote; diff --git a/crates/bevy_reflect/derive/src/impls/func/from_arg.rs b/crates/bevy_reflect/derive/src/impls/func/from_arg.rs index ec663a103e..77b984e04a 100644 --- a/crates/bevy_reflect/derive/src/impls/func/from_arg.rs +++ b/crates/bevy_reflect/derive/src/impls/func/from_arg.rs @@ -1,5 +1,4 @@ -use crate::derive_data::ReflectMeta; -use crate::where_clause_options::WhereClauseOptions; +use crate::{derive_data::ReflectMeta, where_clause_options::WhereClauseOptions}; use bevy_macro_utils::fq_std::FQResult; use quote::quote; diff --git a/crates/bevy_reflect/derive/src/impls/func/function_impls.rs b/crates/bevy_reflect/derive/src/impls/func/function_impls.rs index 1696f906f6..64ca7ca7b7 100644 --- a/crates/bevy_reflect/derive/src/impls/func/function_impls.rs +++ b/crates/bevy_reflect/derive/src/impls/func/function_impls.rs @@ -1,8 +1,10 @@ -use crate::derive_data::ReflectMeta; -use crate::impls::func::from_arg::impl_from_arg; -use crate::impls::func::get_ownership::impl_get_ownership; -use crate::impls::func::into_return::impl_into_return; -use crate::where_clause_options::WhereClauseOptions; +use crate::{ + derive_data::ReflectMeta, + impls::func::{ + from_arg::impl_from_arg, get_ownership::impl_get_ownership, into_return::impl_into_return, + }, + where_clause_options::WhereClauseOptions, +}; use quote::quote; pub(crate) fn impl_function_traits( diff --git a/crates/bevy_reflect/derive/src/impls/func/get_ownership.rs b/crates/bevy_reflect/derive/src/impls/func/get_ownership.rs index f04a9cad39..01d33eb7bb 100644 --- a/crates/bevy_reflect/derive/src/impls/func/get_ownership.rs +++ b/crates/bevy_reflect/derive/src/impls/func/get_ownership.rs @@ -1,5 +1,4 @@ -use crate::derive_data::ReflectMeta; -use crate::where_clause_options::WhereClauseOptions; +use crate::{derive_data::ReflectMeta, where_clause_options::WhereClauseOptions}; use quote::quote; pub(crate) fn impl_get_ownership( diff --git a/crates/bevy_reflect/derive/src/impls/func/into_return.rs b/crates/bevy_reflect/derive/src/impls/func/into_return.rs index 7359184e62..c47c328f9a 100644 --- a/crates/bevy_reflect/derive/src/impls/func/into_return.rs +++ b/crates/bevy_reflect/derive/src/impls/func/into_return.rs @@ -1,5 +1,4 @@ -use crate::derive_data::ReflectMeta; -use crate::where_clause_options::WhereClauseOptions; +use crate::{derive_data::ReflectMeta, where_clause_options::WhereClauseOptions}; use quote::quote; pub(crate) fn impl_into_return( diff --git a/crates/bevy_reflect/derive/src/impls/opaque.rs b/crates/bevy_reflect/derive/src/impls/opaque.rs index 5391dae6d6..eb8fb9f4e0 100644 --- a/crates/bevy_reflect/derive/src/impls/opaque.rs +++ b/crates/bevy_reflect/derive/src/impls/opaque.rs @@ -1,6 +1,8 @@ -use crate::impls::{common_partial_reflect_methods, impl_full_reflect, impl_type_path, impl_typed}; -use crate::where_clause_options::WhereClauseOptions; -use crate::ReflectMeta; +use crate::{ + impls::{common_partial_reflect_methods, impl_full_reflect, impl_type_path, impl_typed}, + where_clause_options::WhereClauseOptions, + ReflectMeta, +}; use bevy_macro_utils::fq_std::{FQBox, FQClone, FQOption, FQResult}; use quote::quote; diff --git a/crates/bevy_reflect/derive/src/impls/structs.rs b/crates/bevy_reflect/derive/src/impls/structs.rs index 15b11d4dd9..fa1b454cfc 100644 --- a/crates/bevy_reflect/derive/src/impls/structs.rs +++ b/crates/bevy_reflect/derive/src/impls/structs.rs @@ -1,6 +1,8 @@ -use crate::impls::{common_partial_reflect_methods, impl_full_reflect, impl_type_path, impl_typed}; -use crate::struct_utility::FieldAccessors; -use crate::ReflectStruct; +use crate::{ + impls::{common_partial_reflect_methods, impl_full_reflect, impl_type_path, impl_typed}, + struct_utility::FieldAccessors, + ReflectStruct, +}; use bevy_macro_utils::fq_std::{FQBox, FQDefault, FQOption, FQResult}; use quote::{quote, ToTokens}; diff --git a/crates/bevy_reflect/derive/src/impls/tuple_structs.rs b/crates/bevy_reflect/derive/src/impls/tuple_structs.rs index fc2228e70e..f0f3cc8f2b 100644 --- a/crates/bevy_reflect/derive/src/impls/tuple_structs.rs +++ b/crates/bevy_reflect/derive/src/impls/tuple_structs.rs @@ -1,6 +1,8 @@ -use crate::impls::{common_partial_reflect_methods, impl_full_reflect, impl_type_path, impl_typed}; -use crate::struct_utility::FieldAccessors; -use crate::ReflectStruct; +use crate::{ + impls::{common_partial_reflect_methods, impl_full_reflect, impl_type_path, impl_typed}, + struct_utility::FieldAccessors, + ReflectStruct, +}; use bevy_macro_utils::fq_std::{FQBox, FQDefault, FQOption, FQResult}; use quote::{quote, ToTokens}; diff --git a/crates/bevy_reflect/derive/src/impls/typed.rs b/crates/bevy_reflect/derive/src/impls/typed.rs index ee8046f682..b158973a7b 100644 --- a/crates/bevy_reflect/derive/src/impls/typed.rs +++ b/crates/bevy_reflect/derive/src/impls/typed.rs @@ -1,6 +1,8 @@ -use crate::derive_data::{ReflectMeta, ReflectTypePath}; -use crate::string_expr::StringExpr; -use crate::where_clause_options::WhereClauseOptions; +use crate::{ + derive_data::{ReflectMeta, ReflectTypePath}, + string_expr::StringExpr, + where_clause_options::WhereClauseOptions, +}; use bevy_macro_utils::fq_std::FQOption; use proc_macro2::TokenStream; use quote::{quote, ToTokens}; diff --git a/crates/bevy_reflect/derive/src/reflect_opaque.rs b/crates/bevy_reflect/derive/src/reflect_opaque.rs index 24b92dbeae..7cebcd7aff 100644 --- a/crates/bevy_reflect/derive/src/reflect_opaque.rs +++ b/crates/bevy_reflect/derive/src/reflect_opaque.rs @@ -1,9 +1,8 @@ -use crate::container_attributes::ContainerAttributes; -use crate::derive_data::ReflectTraitToImpl; -use crate::type_path::CustomPathDef; -use syn::parse::ParseStream; -use syn::token::Paren; -use syn::{parenthesized, Attribute, Generics, Path}; +use crate::{ + container_attributes::ContainerAttributes, derive_data::ReflectTraitToImpl, + type_path::CustomPathDef, +}; +use syn::{parenthesized, parse::ParseStream, token::Paren, Attribute, Generics, Path}; /// A struct used to define a simple reflection-opaque types (including primitives). /// diff --git a/crates/bevy_reflect/derive/src/registration.rs b/crates/bevy_reflect/derive/src/registration.rs index 6210b4358b..f60791215c 100644 --- a/crates/bevy_reflect/derive/src/registration.rs +++ b/crates/bevy_reflect/derive/src/registration.rs @@ -1,8 +1,9 @@ //! Contains code related specifically to Bevy's type registration. -use crate::derive_data::ReflectMeta; -use crate::serialization::SerializationDataDef; -use crate::where_clause_options::WhereClauseOptions; +use crate::{ + derive_data::ReflectMeta, serialization::SerializationDataDef, + where_clause_options::WhereClauseOptions, +}; use quote::quote; use syn::Type; diff --git a/crates/bevy_reflect/derive/src/remote.rs b/crates/bevy_reflect/derive/src/remote.rs index dab2d0562b..2ef657ffa7 100644 --- a/crates/bevy_reflect/derive/src/remote.rs +++ b/crates/bevy_reflect/derive/src/remote.rs @@ -1,16 +1,21 @@ -use crate::derive_data::{ReflectImplSource, ReflectProvenance, ReflectTraitToImpl}; -use crate::ident::ident_or_index; -use crate::impls::impl_assertions; -use crate::{from_reflect, impls, ReflectDerive, REFLECT_ATTRIBUTE_NAME}; +use crate::{ + derive_data::{ReflectImplSource, ReflectProvenance, ReflectTraitToImpl}, + from_reflect, + ident::ident_or_index, + impls, + impls::impl_assertions, + ReflectDerive, REFLECT_ATTRIBUTE_NAME, +}; use bevy_macro_utils::fq_std::FQOption; use proc_macro::TokenStream; use proc_macro2::{Ident, Span}; use quote::{format_ident, quote, quote_spanned}; -use syn::parse::{Parse, ParseStream}; -use syn::spanned::Spanned; -use syn::token::PathSep; use syn::{ - parse_macro_input, DeriveInput, ExprPath, Generics, Member, PathArguments, Type, TypePath, + parse::{Parse, ParseStream}, + parse_macro_input, + spanned::Spanned, + token::PathSep, + DeriveInput, ExprPath, Generics, Member, PathArguments, Type, TypePath, }; /// Generates the remote wrapper type and implements all the necessary traits. diff --git a/crates/bevy_reflect/derive/src/serialization.rs b/crates/bevy_reflect/derive/src/serialization.rs index 0242947b5c..a1ea937894 100644 --- a/crates/bevy_reflect/derive/src/serialization.rs +++ b/crates/bevy_reflect/derive/src/serialization.rs @@ -1,10 +1,11 @@ -use crate::derive_data::StructField; -use crate::field_attributes::{DefaultBehavior, ReflectIgnoreBehavior}; +use crate::{ + derive_data::StructField, + field_attributes::{DefaultBehavior, ReflectIgnoreBehavior}, +}; use bevy_macro_utils::fq_std::{FQBox, FQDefault}; use quote::quote; use std::collections::HashMap; -use syn::spanned::Spanned; -use syn::Path; +use syn::{spanned::Spanned, Path}; type ReflectionIndex = usize; diff --git a/crates/bevy_reflect/derive/src/struct_utility.rs b/crates/bevy_reflect/derive/src/struct_utility.rs index df9279c874..ffad10a06a 100644 --- a/crates/bevy_reflect/derive/src/struct_utility.rs +++ b/crates/bevy_reflect/derive/src/struct_utility.rs @@ -1,5 +1,4 @@ -use crate::derive_data::StructField; -use crate::ReflectStruct; +use crate::{derive_data::StructField, ReflectStruct}; use quote::quote; /// A helper struct for creating remote-aware field accessors. diff --git a/crates/bevy_reflect/derive/src/where_clause_options.rs b/crates/bevy_reflect/derive/src/where_clause_options.rs index 1ada82c534..1551e008d0 100644 --- a/crates/bevy_reflect/derive/src/where_clause_options.rs +++ b/crates/bevy_reflect/derive/src/where_clause_options.rs @@ -2,8 +2,7 @@ use crate::derive_data::ReflectMeta; use bevy_macro_utils::fq_std::{FQAny, FQSend, FQSync}; use proc_macro2::TokenStream; use quote::{quote, ToTokens}; -use syn::punctuated::Punctuated; -use syn::{Token, Type, WhereClause}; +use syn::{punctuated::Punctuated, Token, Type, WhereClause}; /// Options defining how to extend the `where` clause for reflection. pub(crate) struct WhereClauseOptions<'a, 'b> { diff --git a/crates/bevy_reflect/src/array.rs b/crates/bevy_reflect/src/array.rs index 0932a512c5..5b9f2ce916 100644 --- a/crates/bevy_reflect/src/array.rs +++ b/crates/bevy_reflect/src/array.rs @@ -1,7 +1,7 @@ -use crate::type_info::impl_type_methods; use crate::{ - self as bevy_reflect, utility::reflect_hasher, ApplyError, MaybeTyped, PartialReflect, Reflect, - ReflectKind, ReflectMut, ReflectOwned, ReflectRef, Type, TypeInfo, TypePath, + self as bevy_reflect, type_info::impl_type_methods, utility::reflect_hasher, ApplyError, + MaybeTyped, PartialReflect, Reflect, ReflectKind, ReflectMut, ReflectOwned, ReflectRef, Type, + TypeInfo, TypePath, }; use bevy_reflect_derive::impl_type_path; use std::{ @@ -92,7 +92,6 @@ impl ArrayInfo { /// # Arguments /// /// * `capacity`: The maximum capacity of the underlying array. - /// pub fn new( capacity: usize, ) -> Self { @@ -405,7 +404,6 @@ pub fn array_hash(array: &A) -> Option { /// /// * Panics if the two arrays have differing lengths. /// * Panics if the reflected value is not a [valid array](ReflectRef::Array). -/// #[inline] pub fn array_apply(array: &mut A, reflect: &dyn PartialReflect) { if let ReflectRef::Array(reflect_array) = reflect.reflect_ref() { @@ -430,7 +428,6 @@ pub fn array_apply(array: &mut A, reflect: &dyn PartialReflec /// * Returns an [`ApplyError::MismatchedKinds`] if the reflected value is not a /// [valid array](ReflectRef::Array). /// * Returns any error that is generated while applying elements to each other. -/// #[inline] pub fn array_try_apply( array: &mut A, diff --git a/crates/bevy_reflect/src/attributes.rs b/crates/bevy_reflect/src/attributes.rs index a567b71716..c25093a672 100644 --- a/crates/bevy_reflect/src/attributes.rs +++ b/crates/bevy_reflect/src/attributes.rs @@ -132,7 +132,6 @@ impl Debug for CustomAttribute { /// * `$attributes` - The name of the field containing the [`CustomAttributes`]. /// * `$term` - (Optional) The term used to describe the type containing the custom attributes. /// This is purely used to generate better documentation. Defaults to `"item"`. -/// macro_rules! impl_custom_attribute_methods { ($self:ident . $attributes:ident, $term:literal) => { $crate::attributes::impl_custom_attribute_methods!($self, &$self.$attributes, "item"); @@ -178,8 +177,7 @@ pub(crate) use impl_custom_attribute_methods; mod tests { use super::*; use crate as bevy_reflect; - use crate::type_info::Typed; - use crate::{TypeInfo, VariantInfo}; + use crate::{type_info::Typed, TypeInfo, VariantInfo}; use std::ops::RangeInclusive; #[derive(Reflect, PartialEq, Debug)] diff --git a/crates/bevy_reflect/src/enums/dynamic_enum.rs b/crates/bevy_reflect/src/enums/dynamic_enum.rs index ff8165158a..5b3f813e14 100644 --- a/crates/bevy_reflect/src/enums/dynamic_enum.rs +++ b/crates/bevy_reflect/src/enums/dynamic_enum.rs @@ -84,7 +84,6 @@ impl DynamicEnum { /// /// * `variant_name`: The name of the variant to set /// * `variant`: The variant data - /// pub fn new, V: Into>(variant_name: I, variant: V) -> Self { Self { represented_type: None, @@ -101,7 +100,6 @@ impl DynamicEnum { /// * `variant_index`: The index of the variant to set /// * `variant_name`: The name of the variant to set /// * `variant`: The variant data - /// pub fn new_with_index, V: Into>( variant_index: usize, variant_name: I, diff --git a/crates/bevy_reflect/src/enums/enum_trait.rs b/crates/bevy_reflect/src/enums/enum_trait.rs index f3fe336fcc..cc8dfb6200 100644 --- a/crates/bevy_reflect/src/enums/enum_trait.rs +++ b/crates/bevy_reflect/src/enums/enum_trait.rs @@ -1,9 +1,10 @@ -use crate::attributes::{impl_custom_attribute_methods, CustomAttributes}; -use crate::type_info::impl_type_methods; -use crate::{DynamicEnum, PartialReflect, Type, TypePath, VariantInfo, VariantType}; +use crate::{ + attributes::{impl_custom_attribute_methods, CustomAttributes}, + type_info::impl_type_methods, + DynamicEnum, PartialReflect, Type, TypePath, VariantInfo, VariantType, +}; use bevy_utils::HashMap; -use std::slice::Iter; -use std::sync::Arc; +use std::{slice::Iter, sync::Arc}; /// A trait used to power [enum-like] operations via [reflection]. /// @@ -150,7 +151,6 @@ impl EnumInfo { /// # Arguments /// /// * `variants`: The variants of this enum in the order they are defined - /// pub fn new(variants: &[VariantInfo]) -> Self { let variant_indices = variants .iter() diff --git a/crates/bevy_reflect/src/enums/helpers.rs b/crates/bevy_reflect/src/enums/helpers.rs index 6771b1b165..e92580527f 100644 --- a/crates/bevy_reflect/src/enums/helpers.rs +++ b/crates/bevy_reflect/src/enums/helpers.rs @@ -1,7 +1,8 @@ -use crate::PartialReflect; -use crate::{utility::reflect_hasher, Enum, ReflectRef, VariantType}; -use std::fmt::Debug; -use std::hash::{Hash, Hasher}; +use crate::{utility::reflect_hasher, Enum, PartialReflect, ReflectRef, VariantType}; +use std::{ + fmt::Debug, + hash::{Hash, Hasher}, +}; /// Returns the `u64` hash of the given [enum](Enum). #[inline] diff --git a/crates/bevy_reflect/src/enums/variants.rs b/crates/bevy_reflect/src/enums/variants.rs index fb6baf652e..a4dbc0fa4f 100644 --- a/crates/bevy_reflect/src/enums/variants.rs +++ b/crates/bevy_reflect/src/enums/variants.rs @@ -1,5 +1,7 @@ -use crate::attributes::{impl_custom_attribute_methods, CustomAttributes}; -use crate::{NamedField, UnnamedField}; +use crate::{ + attributes::{impl_custom_attribute_methods, CustomAttributes}, + NamedField, UnnamedField, +}; use bevy_utils::HashMap; use std::slice::Iter; diff --git a/crates/bevy_reflect/src/fields.rs b/crates/bevy_reflect/src/fields.rs index 56f6a25879..d535b9f002 100644 --- a/crates/bevy_reflect/src/fields.rs +++ b/crates/bevy_reflect/src/fields.rs @@ -1,6 +1,8 @@ -use crate::attributes::{impl_custom_attribute_methods, CustomAttributes}; -use crate::type_info::impl_type_methods; -use crate::{MaybeTyped, PartialReflect, Type, TypeInfo, TypePath}; +use crate::{ + attributes::{impl_custom_attribute_methods, CustomAttributes}, + type_info::impl_type_methods, + MaybeTyped, PartialReflect, Type, TypeInfo, TypePath, +}; use std::sync::Arc; /// The named field of a reflected struct. diff --git a/crates/bevy_reflect/src/func/args/arg.rs b/crates/bevy_reflect/src/func/args/arg.rs index 14c02eecf1..1ef415591a 100644 --- a/crates/bevy_reflect/src/func/args/arg.rs +++ b/crates/bevy_reflect/src/func/args/arg.rs @@ -1,5 +1,7 @@ -use crate::func::args::{ArgError, FromArg, Ownership}; -use crate::{PartialReflect, Reflect, TypePath}; +use crate::{ + func::args::{ArgError, FromArg, Ownership}, + PartialReflect, Reflect, TypePath, +}; use std::ops::Deref; /// Represents an argument that can be passed to a [`DynamicFunction`] or [`DynamicFunctionMut`]. diff --git a/crates/bevy_reflect/src/func/args/info.rs b/crates/bevy_reflect/src/func/args/info.rs index 3c1098637c..b1a81f3059 100644 --- a/crates/bevy_reflect/src/func/args/info.rs +++ b/crates/bevy_reflect/src/func/args/info.rs @@ -1,8 +1,10 @@ use alloc::borrow::Cow; -use crate::func::args::{GetOwnership, Ownership}; -use crate::type_info::impl_type_methods; -use crate::{Type, TypePath}; +use crate::{ + func::args::{GetOwnership, Ownership}, + type_info::impl_type_methods, + Type, TypePath, +}; /// Type information for an [`Arg`] used in a [`DynamicFunction`] or [`DynamicFunctionMut`]. /// diff --git a/crates/bevy_reflect/src/func/args/list.rs b/crates/bevy_reflect/src/func/args/list.rs index 15458250f4..2021a8b422 100644 --- a/crates/bevy_reflect/src/func/args/list.rs +++ b/crates/bevy_reflect/src/func/args/list.rs @@ -1,6 +1,10 @@ -use crate::func::args::{Arg, ArgValue, FromArg}; -use crate::func::ArgError; -use crate::{PartialReflect, Reflect, TypePath}; +use crate::{ + func::{ + args::{Arg, ArgValue, FromArg}, + ArgError, + }, + PartialReflect, Reflect, TypePath, +}; use std::collections::VecDeque; /// A list of arguments that can be passed to a [`DynamicFunction`] or [`DynamicFunctionMut`]. diff --git a/crates/bevy_reflect/src/func/dynamic_function.rs b/crates/bevy_reflect/src/func/dynamic_function.rs index dcaa051c00..926205c29f 100644 --- a/crates/bevy_reflect/src/func/dynamic_function.rs +++ b/crates/bevy_reflect/src/func/dynamic_function.rs @@ -1,12 +1,11 @@ use crate as bevy_reflect; -use crate::__macro_exports::RegisterForReflection; -use crate::func::args::ArgList; -use crate::func::info::FunctionInfo; -use crate::func::{ - DynamicFunctionMut, Function, FunctionError, FunctionResult, IntoFunction, IntoFunctionMut, -}; -use crate::serde::Serializable; use crate::{ + __macro_exports::RegisterForReflection, + func::{ + args::ArgList, info::FunctionInfo, DynamicFunctionMut, Function, FunctionError, + FunctionResult, IntoFunction, IntoFunctionMut, + }, + serde::Serializable, ApplyError, MaybeTyped, PartialReflect, Reflect, ReflectKind, ReflectMut, ReflectOwned, ReflectRef, TypeInfo, TypePath, }; diff --git a/crates/bevy_reflect/src/func/dynamic_function_mut.rs b/crates/bevy_reflect/src/func/dynamic_function_mut.rs index d39202a1f6..e17f6bc67f 100644 --- a/crates/bevy_reflect/src/func/dynamic_function_mut.rs +++ b/crates/bevy_reflect/src/func/dynamic_function_mut.rs @@ -1,9 +1,10 @@ use alloc::borrow::Cow; use core::fmt::{Debug, Formatter}; -use crate::func::args::ArgList; -use crate::func::info::FunctionInfo; -use crate::func::{DynamicFunction, FunctionError, FunctionResult, IntoFunctionMut}; +use crate::func::{ + args::ArgList, info::FunctionInfo, DynamicFunction, FunctionError, FunctionResult, + IntoFunctionMut, +}; /// A dynamic representation of a function. /// diff --git a/crates/bevy_reflect/src/func/error.rs b/crates/bevy_reflect/src/func/error.rs index a37123f1b6..3d4f3d0a8b 100644 --- a/crates/bevy_reflect/src/func/error.rs +++ b/crates/bevy_reflect/src/func/error.rs @@ -1,5 +1,4 @@ -use crate::func::args::ArgError; -use crate::func::Return; +use crate::func::{args::ArgError, Return}; use alloc::borrow::Cow; use thiserror::Error; diff --git a/crates/bevy_reflect/src/func/function.rs b/crates/bevy_reflect/src/func/function.rs index f70cfbf9c2..3e157a2a81 100644 --- a/crates/bevy_reflect/src/func/function.rs +++ b/crates/bevy_reflect/src/func/function.rs @@ -1,5 +1,7 @@ -use crate::func::{ArgList, DynamicFunction, FunctionInfo, FunctionResult}; -use crate::PartialReflect; +use crate::{ + func::{ArgList, DynamicFunction, FunctionInfo, FunctionResult}, + PartialReflect, +}; use alloc::borrow::Cow; use core::fmt::Debug; diff --git a/crates/bevy_reflect/src/func/info.rs b/crates/bevy_reflect/src/func/info.rs index 8627424dd0..1a93342f6d 100644 --- a/crates/bevy_reflect/src/func/info.rs +++ b/crates/bevy_reflect/src/func/info.rs @@ -2,9 +2,11 @@ use alloc::borrow::Cow; use bevy_utils::all_tuples; -use crate::func::args::{ArgInfo, GetOwnership, Ownership}; -use crate::type_info::impl_type_methods; -use crate::{Type, TypePath}; +use crate::{ + func::args::{ArgInfo, GetOwnership, Ownership}, + type_info::impl_type_methods, + Type, TypePath, +}; /// Type information for a [`DynamicFunction`] or [`DynamicFunctionMut`]. /// diff --git a/crates/bevy_reflect/src/func/mod.rs b/crates/bevy_reflect/src/func/mod.rs index 0a5b1d7895..6e07f0bef1 100644 --- a/crates/bevy_reflect/src/func/mod.rs +++ b/crates/bevy_reflect/src/func/mod.rs @@ -159,8 +159,10 @@ mod return_type; mod tests { use alloc::borrow::Cow; - use crate::func::args::{ArgError, ArgList, Ownership}; - use crate::TypePath; + use crate::{ + func::args::{ArgError, ArgList, Ownership}, + TypePath, + }; use super::*; diff --git a/crates/bevy_reflect/src/func/reflect_fn.rs b/crates/bevy_reflect/src/func/reflect_fn.rs index 1dc1d31302..6e29fd4e07 100644 --- a/crates/bevy_reflect/src/func/reflect_fn.rs +++ b/crates/bevy_reflect/src/func/reflect_fn.rs @@ -1,9 +1,12 @@ use bevy_utils::all_tuples; -use crate::func::args::FromArg; -use crate::func::macros::count_tokens; -use crate::func::{ArgList, FunctionError, FunctionResult, IntoReturn, ReflectFnMut}; -use crate::{Reflect, TypePath}; +use crate::{ + func::{ + args::FromArg, macros::count_tokens, ArgList, FunctionError, FunctionResult, IntoReturn, + ReflectFnMut, + }, + Reflect, TypePath, +}; /// A reflection-based version of the [`Fn`] trait. /// diff --git a/crates/bevy_reflect/src/func/reflect_fn_mut.rs b/crates/bevy_reflect/src/func/reflect_fn_mut.rs index a6a6bd6e9f..be73aca79b 100644 --- a/crates/bevy_reflect/src/func/reflect_fn_mut.rs +++ b/crates/bevy_reflect/src/func/reflect_fn_mut.rs @@ -1,9 +1,11 @@ use bevy_utils::all_tuples; -use crate::func::args::FromArg; -use crate::func::macros::count_tokens; -use crate::func::{ArgList, FunctionError, FunctionResult, IntoReturn}; -use crate::{Reflect, TypePath}; +use crate::{ + func::{ + args::FromArg, macros::count_tokens, ArgList, FunctionError, FunctionResult, IntoReturn, + }, + Reflect, TypePath, +}; /// A reflection-based version of the [`FnMut`] trait. /// diff --git a/crates/bevy_reflect/src/func/registry.rs b/crates/bevy_reflect/src/func/registry.rs index 2c88ef509a..40a1d4cbe1 100644 --- a/crates/bevy_reflect/src/func/registry.rs +++ b/crates/bevy_reflect/src/func/registry.rs @@ -144,7 +144,7 @@ impl FunctionRegistry { /// /// Another approach could be to use the [type name] of the function, /// however, it should be noted that anonymous functions and closures - ///are not guaranteed to have unique type names. + /// are not guaranteed to have unique type names. /// /// This method is a convenience around calling [`IntoFunction::into_function`] and [`DynamicFunction::with_name`] /// on the function and inserting it into the registry using the [`register`] method. diff --git a/crates/bevy_reflect/src/impls/smallvec.rs b/crates/bevy_reflect/src/impls/smallvec.rs index fa3d66b6bc..dd8f06e2f3 100644 --- a/crates/bevy_reflect/src/impls/smallvec.rs +++ b/crates/bevy_reflect/src/impls/smallvec.rs @@ -3,11 +3,11 @@ use smallvec::{Array as SmallArray, SmallVec}; use std::any::Any; -use crate::utility::GenericTypeInfoCell; use crate::{ - self as bevy_reflect, ApplyError, FromReflect, FromType, GetTypeRegistration, List, ListInfo, - ListIter, MaybeTyped, PartialReflect, Reflect, ReflectFromPtr, ReflectKind, ReflectMut, - ReflectOwned, ReflectRef, TypeInfo, TypePath, TypeRegistration, Typed, + self as bevy_reflect, utility::GenericTypeInfoCell, ApplyError, FromReflect, FromType, + GetTypeRegistration, List, ListInfo, ListIter, MaybeTyped, PartialReflect, Reflect, + ReflectFromPtr, ReflectKind, ReflectMut, ReflectOwned, ReflectRef, TypeInfo, TypePath, + TypeRegistration, Typed, }; impl List for SmallVec diff --git a/crates/bevy_reflect/src/impls/smol_str.rs b/crates/bevy_reflect/src/impls/smol_str.rs index 11e5f9da37..7a0f99e2ed 100644 --- a/crates/bevy_reflect/src/impls/smol_str.rs +++ b/crates/bevy_reflect/src/impls/smol_str.rs @@ -1,5 +1,6 @@ -use crate::{self as bevy_reflect}; -use crate::{std_traits::ReflectDefault, ReflectDeserialize, ReflectSerialize}; +use crate::{ + self as bevy_reflect, std_traits::ReflectDefault, ReflectDeserialize, ReflectSerialize, +}; use bevy_reflect_derive::impl_reflect_opaque; impl_reflect_opaque!(::smol_str::SmolStr( diff --git a/crates/bevy_reflect/src/impls/std.rs b/crates/bevy_reflect/src/impls/std.rs index e62b3b4e14..284216dce0 100644 --- a/crates/bevy_reflect/src/impls/std.rs +++ b/crates/bevy_reflect/src/impls/std.rs @@ -1,25 +1,24 @@ // Temporary workaround for impl_reflect!(Option/Result false-positive #![allow(unused_qualifications)] -use crate::std_traits::ReflectDefault; -use crate::utility::{ - reflect_hasher, GenericTypeInfoCell, GenericTypePathCell, NonGenericTypeInfoCell, -}; use crate::{ self as bevy_reflect, impl_type_path, map_apply, map_partial_eq, map_try_apply, - reflect::impl_full_reflect, set_apply, set_partial_eq, set_try_apply, ApplyError, Array, - ArrayInfo, ArrayIter, DynamicMap, DynamicSet, DynamicTypePath, FromReflect, FromType, - GetTypeRegistration, List, ListInfo, ListIter, Map, MapInfo, MapIter, MaybeTyped, OpaqueInfo, - PartialReflect, Reflect, ReflectDeserialize, ReflectFromPtr, ReflectFromReflect, ReflectKind, - ReflectMut, ReflectOwned, ReflectRef, ReflectSerialize, Set, SetInfo, TypeInfo, TypePath, - TypeRegistration, TypeRegistry, Typed, + reflect::impl_full_reflect, + set_apply, set_partial_eq, set_try_apply, + std_traits::ReflectDefault, + utility::{reflect_hasher, GenericTypeInfoCell, GenericTypePathCell, NonGenericTypeInfoCell}, + ApplyError, Array, ArrayInfo, ArrayIter, DynamicMap, DynamicSet, DynamicTypePath, FromReflect, + FromType, GetTypeRegistration, List, ListInfo, ListIter, Map, MapInfo, MapIter, MaybeTyped, + OpaqueInfo, PartialReflect, Reflect, ReflectDeserialize, ReflectFromPtr, ReflectFromReflect, + ReflectKind, ReflectMut, ReflectOwned, ReflectRef, ReflectSerialize, Set, SetInfo, TypeInfo, + TypePath, TypeRegistration, TypeRegistry, Typed, }; use bevy_reflect_derive::{impl_reflect, impl_reflect_opaque}; -use std::fmt; use std::{ any::Any, borrow::Cow, collections::VecDeque, + fmt, hash::{BuildHasher, Hash, Hasher}, path::Path, }; @@ -2225,17 +2224,17 @@ crate::func::macros::impl_function_traits!(Cow<'static, Path>); #[cfg(test)] mod tests { - use crate::{self as bevy_reflect, PartialReflect}; use crate::{ - Enum, FromReflect, Reflect, ReflectSerialize, TypeInfo, TypeRegistry, Typed, VariantInfo, - VariantType, + self as bevy_reflect, Enum, FromReflect, PartialReflect, Reflect, ReflectSerialize, + TypeInfo, TypeRegistry, Typed, VariantInfo, VariantType, }; - use bevy_utils::HashMap; - use bevy_utils::{Duration, Instant}; + use bevy_utils::{Duration, HashMap, Instant}; use static_assertions::assert_impl_all; - use std::collections::BTreeMap; - use std::f32::consts::{PI, TAU}; - use std::path::Path; + use std::{ + collections::BTreeMap, + f32::consts::{PI, TAU}, + path::Path, + }; #[test] fn can_serialize_duration() { diff --git a/crates/bevy_reflect/src/lib.rs b/crates/bevy_reflect/src/lib.rs index 4bdc65b318..37198e9a5c 100644 --- a/crates/bevy_reflect/src/lib.rs +++ b/crates/bevy_reflect/src/lib.rs @@ -694,11 +694,12 @@ mod tests { marker::PhantomData, }; - use super::prelude::*; - use super::*; + use super::{prelude::*, *}; use crate as bevy_reflect; - use crate::serde::{ReflectDeserializer, ReflectSerializer}; - use crate::utility::GenericTypePathCell; + use crate::{ + serde::{ReflectDeserializer, ReflectSerializer}, + utility::GenericTypePathCell, + }; #[test] fn try_apply_should_detect_kinds() { @@ -1899,10 +1900,8 @@ mod tests { let info = ::type_info(); assert_eq!(None, info.docs()); - /* - * Block comments do not count as doc comments, - * and are therefore not reflected. - */ + // Block comments do not count as doc comments, + // and are therefore not reflected. #[derive(Reflect)] struct SomeOtherStruct; diff --git a/crates/bevy_reflect/src/list.rs b/crates/bevy_reflect/src/list.rs index 784d00231f..5ab3107bb1 100644 --- a/crates/bevy_reflect/src/list.rs +++ b/crates/bevy_reflect/src/list.rs @@ -1,14 +1,15 @@ -use std::any::Any; -use std::fmt::{Debug, Formatter}; -use std::hash::{Hash, Hasher}; +use std::{ + any::Any, + fmt::{Debug, Formatter}, + hash::{Hash, Hasher}, +}; use bevy_reflect_derive::impl_type_path; -use crate::type_info::impl_type_methods; -use crate::utility::reflect_hasher; use crate::{ - self as bevy_reflect, ApplyError, FromReflect, MaybeTyped, PartialReflect, Reflect, - ReflectKind, ReflectMut, ReflectOwned, ReflectRef, Type, TypeInfo, TypePath, + self as bevy_reflect, type_info::impl_type_methods, utility::reflect_hasher, ApplyError, + FromReflect, MaybeTyped, PartialReflect, Reflect, ReflectKind, ReflectMut, ReflectOwned, + ReflectRef, Type, TypeInfo, TypePath, }; /// A trait used to power [list-like] operations via [reflection]. diff --git a/crates/bevy_reflect/src/map.rs b/crates/bevy_reflect/src/map.rs index c21762f7cb..fc1fd25b9b 100644 --- a/crates/bevy_reflect/src/map.rs +++ b/crates/bevy_reflect/src/map.rs @@ -3,10 +3,9 @@ use std::fmt::{Debug, Formatter}; use bevy_reflect_derive::impl_type_path; use bevy_utils::{Entry, HashMap}; -use crate::type_info::impl_type_methods; use crate::{ - self as bevy_reflect, ApplyError, MaybeTyped, PartialReflect, Reflect, ReflectKind, ReflectMut, - ReflectOwned, ReflectRef, Type, TypeInfo, TypePath, + self as bevy_reflect, type_info::impl_type_methods, ApplyError, MaybeTyped, PartialReflect, + Reflect, ReflectKind, ReflectMut, ReflectOwned, ReflectRef, Type, TypeInfo, TypePath, }; /// A trait used to power [map-like] operations via [reflection]. @@ -567,8 +566,7 @@ pub fn map_try_apply(a: &mut M, b: &dyn PartialReflect) -> Result<(), Ap #[cfg(test)] mod tests { - use super::DynamicMap; - use super::Map; + use super::{DynamicMap, Map}; #[test] fn test_into_iter() { diff --git a/crates/bevy_reflect/src/path/mod.rs b/crates/bevy_reflect/src/path/mod.rs index ced501c154..610b95d960 100644 --- a/crates/bevy_reflect/src/path/mod.rs +++ b/crates/bevy_reflect/src/path/mod.rs @@ -355,7 +355,6 @@ impl From> for OffsetAccess { /// ]; /// let my_path = ParsedPath::from(path_elements); /// ``` -/// #[derive(Clone, Debug, PartialEq, PartialOrd, Ord, Eq, Hash)] pub struct ParsedPath( /// This is a vector of pre-parsed [`OffsetAccess`]es. @@ -407,7 +406,6 @@ impl ParsedPath { /// /// assert_eq!(parsed_path.element::(&foo).unwrap(), &123); /// ``` - /// pub fn parse(string: &str) -> PathResult { let mut parts = Vec::new(); for (access, offset) in PathParser::new(string) { @@ -573,7 +571,7 @@ mod tests { } } - fn access_field(field: &'static str) -> Access { + fn access_field(field: &'static str) -> Access<'static> { Access::Field(field.into()) } diff --git a/crates/bevy_reflect/src/serde/de/arrays.rs b/crates/bevy_reflect/src/serde/de/arrays.rs index 2ffd2419a9..b1f7b60ffe 100644 --- a/crates/bevy_reflect/src/serde/de/arrays.rs +++ b/crates/bevy_reflect/src/serde/de/arrays.rs @@ -1,6 +1,7 @@ -use crate::serde::de::registration_utils::try_get_registration; -use crate::serde::TypedReflectDeserializer; -use crate::{ArrayInfo, DynamicArray, TypeRegistry}; +use crate::{ + serde::{de::registration_utils::try_get_registration, TypedReflectDeserializer}, + ArrayInfo, DynamicArray, TypeRegistry, +}; use core::fmt::Formatter; use serde::de::{Error, SeqAccess, Visitor}; use std::fmt; diff --git a/crates/bevy_reflect/src/serde/de/deserializer.rs b/crates/bevy_reflect/src/serde/de/deserializer.rs index 46530c2fe0..0bd6be5bf3 100644 --- a/crates/bevy_reflect/src/serde/de/deserializer.rs +++ b/crates/bevy_reflect/src/serde/de/deserializer.rs @@ -1,17 +1,16 @@ -use crate::serde::de::arrays::ArrayVisitor; -use crate::serde::de::enums::EnumVisitor; -use crate::serde::de::error_utils::make_custom_error; #[cfg(feature = "debug_stack")] use crate::serde::de::error_utils::TYPE_INFO_STACK; -use crate::serde::de::lists::ListVisitor; -use crate::serde::de::maps::MapVisitor; -use crate::serde::de::options::OptionVisitor; -use crate::serde::de::sets::SetVisitor; -use crate::serde::de::structs::StructVisitor; -use crate::serde::de::tuple_structs::TupleStructVisitor; -use crate::serde::de::tuples::TupleVisitor; -use crate::serde::TypeRegistrationDeserializer; -use crate::{PartialReflect, ReflectDeserialize, TypeInfo, TypeRegistration, TypeRegistry}; +use crate::{ + serde::{ + de::{ + arrays::ArrayVisitor, enums::EnumVisitor, error_utils::make_custom_error, + lists::ListVisitor, maps::MapVisitor, options::OptionVisitor, sets::SetVisitor, + structs::StructVisitor, tuple_structs::TupleStructVisitor, tuples::TupleVisitor, + }, + TypeRegistrationDeserializer, + }, + PartialReflect, ReflectDeserialize, TypeInfo, TypeRegistration, TypeRegistry, +}; use core::fmt::Formatter; use serde::de::{DeserializeSeed, Error, IgnoredAny, MapAccess, Visitor}; use std::fmt; diff --git a/crates/bevy_reflect/src/serde/de/enums.rs b/crates/bevy_reflect/src/serde/de/enums.rs index 8f4a094e83..90836c31f3 100644 --- a/crates/bevy_reflect/src/serde/de/enums.rs +++ b/crates/bevy_reflect/src/serde/de/enums.rs @@ -1,10 +1,14 @@ -use crate::serde::de::error_utils::make_custom_error; -use crate::serde::de::helpers::ExpectedValues; -use crate::serde::de::registration_utils::try_get_registration; -use crate::serde::de::struct_utils::{visit_struct, visit_struct_seq}; -use crate::serde::de::tuple_utils::{visit_tuple, TupleLikeInfo}; -use crate::serde::TypedReflectDeserializer; use crate::{ + serde::{ + de::{ + error_utils::make_custom_error, + helpers::ExpectedValues, + registration_utils::try_get_registration, + struct_utils::{visit_struct, visit_struct_seq}, + tuple_utils::{visit_tuple, TupleLikeInfo}, + }, + TypedReflectDeserializer, + }, DynamicEnum, DynamicStruct, DynamicTuple, DynamicVariant, EnumInfo, StructVariantInfo, TupleVariantInfo, TypeRegistration, TypeRegistry, VariantInfo, }; diff --git a/crates/bevy_reflect/src/serde/de/helpers.rs b/crates/bevy_reflect/src/serde/de/helpers.rs index 3243a6c011..db4d5a35bb 100644 --- a/crates/bevy_reflect/src/serde/de/helpers.rs +++ b/crates/bevy_reflect/src/serde/de/helpers.rs @@ -1,6 +1,8 @@ use core::fmt::{Debug, Display, Formatter}; -use serde::de::{Error, Visitor}; -use serde::Deserialize; +use serde::{ + de::{Error, Visitor}, + Deserialize, +}; use std::fmt; /// A debug struct used for error messages that displays a list of expected values. diff --git a/crates/bevy_reflect/src/serde/de/lists.rs b/crates/bevy_reflect/src/serde/de/lists.rs index d0387f8a0a..82c5858f99 100644 --- a/crates/bevy_reflect/src/serde/de/lists.rs +++ b/crates/bevy_reflect/src/serde/de/lists.rs @@ -1,6 +1,7 @@ -use crate::serde::de::registration_utils::try_get_registration; -use crate::serde::TypedReflectDeserializer; -use crate::{DynamicList, ListInfo, TypeRegistry}; +use crate::{ + serde::{de::registration_utils::try_get_registration, TypedReflectDeserializer}, + DynamicList, ListInfo, TypeRegistry, +}; use core::fmt::Formatter; use serde::de::{SeqAccess, Visitor}; use std::fmt; diff --git a/crates/bevy_reflect/src/serde/de/maps.rs b/crates/bevy_reflect/src/serde/de/maps.rs index 1bda2e6837..1db1499136 100644 --- a/crates/bevy_reflect/src/serde/de/maps.rs +++ b/crates/bevy_reflect/src/serde/de/maps.rs @@ -1,6 +1,7 @@ -use crate::serde::de::registration_utils::try_get_registration; -use crate::serde::TypedReflectDeserializer; -use crate::{DynamicMap, Map, MapInfo, TypeRegistry}; +use crate::{ + serde::{de::registration_utils::try_get_registration, TypedReflectDeserializer}, + DynamicMap, Map, MapInfo, TypeRegistry, +}; use core::fmt::Formatter; use serde::de::{MapAccess, Visitor}; use std::fmt; diff --git a/crates/bevy_reflect/src/serde/de/mod.rs b/crates/bevy_reflect/src/serde/de/mod.rs index 4b89803e1d..4ba84162c5 100644 --- a/crates/bevy_reflect/src/serde/de/mod.rs +++ b/crates/bevy_reflect/src/serde/de/mod.rs @@ -21,18 +21,15 @@ mod tuples; #[cfg(test)] mod tests { use bincode::Options; - use std::any::TypeId; - use std::f32::consts::PI; - use std::ops::RangeInclusive; + use std::{any::TypeId, f32::consts::PI, ops::RangeInclusive}; - use serde::de::DeserializeSeed; - use serde::Deserialize; + use serde::{de::DeserializeSeed, Deserialize}; use bevy_utils::{HashMap, HashSet}; use crate as bevy_reflect; - use crate::serde::{ReflectDeserializer, ReflectSerializer, TypedReflectDeserializer}; use crate::{ + serde::{ReflectDeserializer, ReflectSerializer, TypedReflectDeserializer}, DynamicEnum, FromReflect, PartialReflect, Reflect, ReflectDeserialize, TypeRegistry, }; diff --git a/crates/bevy_reflect/src/serde/de/options.rs b/crates/bevy_reflect/src/serde/de/options.rs index f4a5467c63..4713e7a8f5 100644 --- a/crates/bevy_reflect/src/serde/de/options.rs +++ b/crates/bevy_reflect/src/serde/de/options.rs @@ -1,7 +1,10 @@ -use crate::serde::de::error_utils::make_custom_error; -use crate::serde::de::registration_utils::try_get_registration; -use crate::serde::TypedReflectDeserializer; -use crate::{DynamicEnum, DynamicTuple, EnumInfo, TypeRegistry, VariantInfo}; +use crate::{ + serde::{ + de::{error_utils::make_custom_error, registration_utils::try_get_registration}, + TypedReflectDeserializer, + }, + DynamicEnum, DynamicTuple, EnumInfo, TypeRegistry, VariantInfo, +}; use core::fmt::Formatter; use serde::de::{DeserializeSeed, Error, Visitor}; use std::fmt; diff --git a/crates/bevy_reflect/src/serde/de/registration_utils.rs b/crates/bevy_reflect/src/serde/de/registration_utils.rs index 2c88a73939..0559af70af 100644 --- a/crates/bevy_reflect/src/serde/de/registration_utils.rs +++ b/crates/bevy_reflect/src/serde/de/registration_utils.rs @@ -1,5 +1,4 @@ -use crate::serde::de::error_utils::make_custom_error; -use crate::{Type, TypeRegistration, TypeRegistry}; +use crate::{serde::de::error_utils::make_custom_error, Type, TypeRegistration, TypeRegistry}; use serde::de::Error; /// Attempts to find the [`TypeRegistration`] for a given [type]. diff --git a/crates/bevy_reflect/src/serde/de/registrations.rs b/crates/bevy_reflect/src/serde/de/registrations.rs index 8b34c348c0..b80ff1874f 100644 --- a/crates/bevy_reflect/src/serde/de/registrations.rs +++ b/crates/bevy_reflect/src/serde/de/registrations.rs @@ -1,5 +1,4 @@ -use crate::serde::de::error_utils::make_custom_error; -use crate::{TypeRegistration, TypeRegistry}; +use crate::{serde::de::error_utils::make_custom_error, TypeRegistration, TypeRegistry}; use core::fmt::Formatter; use serde::de::{DeserializeSeed, Error, Visitor}; use std::fmt; diff --git a/crates/bevy_reflect/src/serde/de/sets.rs b/crates/bevy_reflect/src/serde/de/sets.rs index 2127f84b48..c1f668c960 100644 --- a/crates/bevy_reflect/src/serde/de/sets.rs +++ b/crates/bevy_reflect/src/serde/de/sets.rs @@ -1,6 +1,7 @@ -use crate::serde::de::registration_utils::try_get_registration; -use crate::serde::TypedReflectDeserializer; -use crate::{DynamicSet, Set, SetInfo, TypeRegistry}; +use crate::{ + serde::{de::registration_utils::try_get_registration, TypedReflectDeserializer}, + DynamicSet, Set, SetInfo, TypeRegistry, +}; use core::fmt::Formatter; use serde::de::{SeqAccess, Visitor}; use std::fmt; diff --git a/crates/bevy_reflect/src/serde/de/struct_utils.rs b/crates/bevy_reflect/src/serde/de/struct_utils.rs index 836d36c0bd..0833678753 100644 --- a/crates/bevy_reflect/src/serde/de/struct_utils.rs +++ b/crates/bevy_reflect/src/serde/de/struct_utils.rs @@ -1,8 +1,12 @@ -use crate::serde::de::error_utils::make_custom_error; -use crate::serde::de::helpers::{ExpectedValues, Ident}; -use crate::serde::de::registration_utils::try_get_registration; -use crate::serde::{SerializationData, TypedReflectDeserializer}; use crate::{ + serde::{ + de::{ + error_utils::make_custom_error, + helpers::{ExpectedValues, Ident}, + registration_utils::try_get_registration, + }, + SerializationData, TypedReflectDeserializer, + }, DynamicStruct, NamedField, StructInfo, StructVariantInfo, TypeRegistration, TypeRegistry, }; use core::slice::Iter; diff --git a/crates/bevy_reflect/src/serde/de/structs.rs b/crates/bevy_reflect/src/serde/de/structs.rs index 85aa6f15b3..899e839004 100644 --- a/crates/bevy_reflect/src/serde/de/structs.rs +++ b/crates/bevy_reflect/src/serde/de/structs.rs @@ -1,5 +1,7 @@ -use crate::serde::de::struct_utils::{visit_struct, visit_struct_seq}; -use crate::{DynamicStruct, StructInfo, TypeRegistration, TypeRegistry}; +use crate::{ + serde::de::struct_utils::{visit_struct, visit_struct_seq}, + DynamicStruct, StructInfo, TypeRegistration, TypeRegistry, +}; use core::fmt::Formatter; use serde::de::{MapAccess, SeqAccess, Visitor}; use std::fmt; diff --git a/crates/bevy_reflect/src/serde/de/tuple_structs.rs b/crates/bevy_reflect/src/serde/de/tuple_structs.rs index 8bbe44a324..3817c66c94 100644 --- a/crates/bevy_reflect/src/serde/de/tuple_structs.rs +++ b/crates/bevy_reflect/src/serde/de/tuple_structs.rs @@ -1,5 +1,7 @@ -use crate::serde::de::tuple_utils::visit_tuple; -use crate::{DynamicTupleStruct, TupleStructInfo, TypeRegistration, TypeRegistry}; +use crate::{ + serde::de::tuple_utils::visit_tuple, DynamicTupleStruct, TupleStructInfo, TypeRegistration, + TypeRegistry, +}; use core::fmt::Formatter; use serde::de::{SeqAccess, Visitor}; use std::fmt; diff --git a/crates/bevy_reflect/src/serde/de/tuple_utils.rs b/crates/bevy_reflect/src/serde/de/tuple_utils.rs index 7dd8ad4481..ae49fe4084 100644 --- a/crates/bevy_reflect/src/serde/de/tuple_utils.rs +++ b/crates/bevy_reflect/src/serde/de/tuple_utils.rs @@ -1,7 +1,8 @@ -use crate::serde::de::error_utils::make_custom_error; -use crate::serde::de::registration_utils::try_get_registration; -use crate::serde::{SerializationData, TypedReflectDeserializer}; use crate::{ + serde::{ + de::{error_utils::make_custom_error, registration_utils::try_get_registration}, + SerializationData, TypedReflectDeserializer, + }, DynamicTuple, TupleInfo, TupleStructInfo, TupleVariantInfo, TypeRegistration, TypeRegistry, UnnamedField, }; diff --git a/crates/bevy_reflect/src/serde/de/tuples.rs b/crates/bevy_reflect/src/serde/de/tuples.rs index de18cbda61..f182078186 100644 --- a/crates/bevy_reflect/src/serde/de/tuples.rs +++ b/crates/bevy_reflect/src/serde/de/tuples.rs @@ -1,5 +1,6 @@ -use crate::serde::de::tuple_utils::visit_tuple; -use crate::{DynamicTuple, TupleInfo, TypeRegistration, TypeRegistry}; +use crate::{ + serde::de::tuple_utils::visit_tuple, DynamicTuple, TupleInfo, TypeRegistration, TypeRegistry, +}; use core::fmt::Formatter; use serde::de::{SeqAccess, Visitor}; use std::fmt; diff --git a/crates/bevy_reflect/src/serde/mod.rs b/crates/bevy_reflect/src/serde/mod.rs index bc3137d0b2..5a307c7d18 100644 --- a/crates/bevy_reflect/src/serde/mod.rs +++ b/crates/bevy_reflect/src/serde/mod.rs @@ -8,11 +8,11 @@ pub use type_data::*; #[cfg(test)] mod tests { - use crate::{self as bevy_reflect, DynamicTupleStruct, PartialReflect, Struct}; use crate::{ + self as bevy_reflect, serde::{ReflectDeserializer, ReflectSerializer}, type_registry::TypeRegistry, - DynamicStruct, FromReflect, Reflect, + DynamicStruct, DynamicTupleStruct, FromReflect, PartialReflect, Reflect, Struct, }; use serde::de::DeserializeSeed; diff --git a/crates/bevy_reflect/src/serde/ser/arrays.rs b/crates/bevy_reflect/src/serde/ser/arrays.rs index b318047ee2..16c741a680 100644 --- a/crates/bevy_reflect/src/serde/ser/arrays.rs +++ b/crates/bevy_reflect/src/serde/ser/arrays.rs @@ -1,7 +1,5 @@ -use crate::serde::TypedReflectSerializer; -use crate::{Array, TypeRegistry}; -use serde::ser::SerializeTuple; -use serde::Serialize; +use crate::{serde::TypedReflectSerializer, Array, TypeRegistry}; +use serde::{ser::SerializeTuple, Serialize}; /// A serializer for [`Array`] values. pub(super) struct ArraySerializer<'a> { diff --git a/crates/bevy_reflect/src/serde/ser/enums.rs b/crates/bevy_reflect/src/serde/ser/enums.rs index 6951617cb6..4b71207a97 100644 --- a/crates/bevy_reflect/src/serde/ser/enums.rs +++ b/crates/bevy_reflect/src/serde/ser/enums.rs @@ -1,8 +1,11 @@ -use crate::serde::ser::error_utils::make_custom_error; -use crate::serde::TypedReflectSerializer; -use crate::{Enum, TypeInfo, TypeRegistry, VariantInfo, VariantType}; -use serde::ser::{SerializeStructVariant, SerializeTupleVariant}; -use serde::Serialize; +use crate::{ + serde::{ser::error_utils::make_custom_error, TypedReflectSerializer}, + Enum, TypeInfo, TypeRegistry, VariantInfo, VariantType, +}; +use serde::{ + ser::{SerializeStructVariant, SerializeTupleVariant}, + Serialize, +}; /// A serializer for [`Enum`] values. pub(super) struct EnumSerializer<'a> { diff --git a/crates/bevy_reflect/src/serde/ser/lists.rs b/crates/bevy_reflect/src/serde/ser/lists.rs index ad3bb1a040..b52d52202f 100644 --- a/crates/bevy_reflect/src/serde/ser/lists.rs +++ b/crates/bevy_reflect/src/serde/ser/lists.rs @@ -1,7 +1,5 @@ -use crate::serde::TypedReflectSerializer; -use crate::{List, TypeRegistry}; -use serde::ser::SerializeSeq; -use serde::Serialize; +use crate::{serde::TypedReflectSerializer, List, TypeRegistry}; +use serde::{ser::SerializeSeq, Serialize}; /// A serializer for [`List`] values. pub(super) struct ListSerializer<'a> { diff --git a/crates/bevy_reflect/src/serde/ser/maps.rs b/crates/bevy_reflect/src/serde/ser/maps.rs index d5493cd35e..354169193b 100644 --- a/crates/bevy_reflect/src/serde/ser/maps.rs +++ b/crates/bevy_reflect/src/serde/ser/maps.rs @@ -1,7 +1,5 @@ -use crate::serde::TypedReflectSerializer; -use crate::{Map, TypeRegistry}; -use serde::ser::SerializeMap; -use serde::Serialize; +use crate::{serde::TypedReflectSerializer, Map, TypeRegistry}; +use serde::{ser::SerializeMap, Serialize}; /// A serializer for [`Map`] values. pub(super) struct MapSerializer<'a> { diff --git a/crates/bevy_reflect/src/serde/ser/mod.rs b/crates/bevy_reflect/src/serde/ser/mod.rs index 30d684d4aa..42274c1563 100644 --- a/crates/bevy_reflect/src/serde/ser/mod.rs +++ b/crates/bevy_reflect/src/serde/ser/mod.rs @@ -15,15 +15,14 @@ mod tuples; #[cfg(test)] mod tests { - use crate::serde::ReflectSerializer; - use crate::{self as bevy_reflect, PartialReflect, Struct}; - use crate::{Reflect, ReflectSerialize, TypeRegistry}; + use crate::{ + self as bevy_reflect, serde::ReflectSerializer, PartialReflect, Reflect, ReflectSerialize, + Struct, TypeRegistry, + }; use bevy_utils::{HashMap, HashSet}; - use ron::extensions::Extensions; - use ron::ser::PrettyConfig; + use ron::{extensions::Extensions, ser::PrettyConfig}; use serde::Serialize; - use std::f32::consts::PI; - use std::ops::RangeInclusive; + use std::{f32::consts::PI, ops::RangeInclusive}; #[derive(Reflect, Debug, PartialEq)] struct MyStruct { diff --git a/crates/bevy_reflect/src/serde/ser/serializable.rs b/crates/bevy_reflect/src/serde/ser/serializable.rs index 9cf96ee77a..80f0ccca98 100644 --- a/crates/bevy_reflect/src/serde/ser/serializable.rs +++ b/crates/bevy_reflect/src/serde/ser/serializable.rs @@ -1,5 +1,6 @@ -use crate::serde::ser::error_utils::make_custom_error; -use crate::{PartialReflect, ReflectSerialize, TypeRegistry}; +use crate::{ + serde::ser::error_utils::make_custom_error, PartialReflect, ReflectSerialize, TypeRegistry, +}; use serde::ser::Error; use std::ops::Deref; diff --git a/crates/bevy_reflect/src/serde/ser/serializer.rs b/crates/bevy_reflect/src/serde/ser/serializer.rs index f6fd518e73..55fad6d8e6 100644 --- a/crates/bevy_reflect/src/serde/ser/serializer.rs +++ b/crates/bevy_reflect/src/serde/ser/serializer.rs @@ -1,18 +1,18 @@ -use crate::serde::ser::arrays::ArraySerializer; -use crate::serde::ser::enums::EnumSerializer; -use crate::serde::ser::error_utils::make_custom_error; #[cfg(feature = "debug_stack")] use crate::serde::ser::error_utils::TYPE_INFO_STACK; -use crate::serde::ser::lists::ListSerializer; -use crate::serde::ser::maps::MapSerializer; -use crate::serde::ser::sets::SetSerializer; -use crate::serde::ser::structs::StructSerializer; -use crate::serde::ser::tuple_structs::TupleStructSerializer; -use crate::serde::ser::tuples::TupleSerializer; -use crate::serde::Serializable; -use crate::{PartialReflect, ReflectRef, TypeRegistry}; -use serde::ser::SerializeMap; -use serde::Serialize; +use crate::{ + serde::{ + ser::{ + arrays::ArraySerializer, enums::EnumSerializer, error_utils::make_custom_error, + lists::ListSerializer, maps::MapSerializer, sets::SetSerializer, + structs::StructSerializer, tuple_structs::TupleStructSerializer, + tuples::TupleSerializer, + }, + Serializable, + }, + PartialReflect, ReflectRef, TypeRegistry, +}; +use serde::{ser::SerializeMap, Serialize}; /// A general purpose serializer for reflected types. /// diff --git a/crates/bevy_reflect/src/serde/ser/sets.rs b/crates/bevy_reflect/src/serde/ser/sets.rs index 846f9e4f84..343c253eb2 100644 --- a/crates/bevy_reflect/src/serde/ser/sets.rs +++ b/crates/bevy_reflect/src/serde/ser/sets.rs @@ -1,7 +1,5 @@ -use crate::serde::TypedReflectSerializer; -use crate::{Set, TypeRegistry}; -use serde::ser::SerializeSeq; -use serde::Serialize; +use crate::{serde::TypedReflectSerializer, Set, TypeRegistry}; +use serde::{ser::SerializeSeq, Serialize}; /// A serializer for [`Set`] values. pub(super) struct SetSerializer<'a> { diff --git a/crates/bevy_reflect/src/serde/ser/structs.rs b/crates/bevy_reflect/src/serde/ser/structs.rs index 7763e297fe..c8c2b87b44 100644 --- a/crates/bevy_reflect/src/serde/ser/structs.rs +++ b/crates/bevy_reflect/src/serde/ser/structs.rs @@ -1,8 +1,8 @@ -use crate::serde::ser::error_utils::make_custom_error; -use crate::serde::{SerializationData, TypedReflectSerializer}; -use crate::{Struct, TypeInfo, TypeRegistry}; -use serde::ser::SerializeStruct; -use serde::Serialize; +use crate::{ + serde::{ser::error_utils::make_custom_error, SerializationData, TypedReflectSerializer}, + Struct, TypeInfo, TypeRegistry, +}; +use serde::{ser::SerializeStruct, Serialize}; /// A serializer for [`Struct`] values. pub(super) struct StructSerializer<'a> { diff --git a/crates/bevy_reflect/src/serde/ser/tuple_structs.rs b/crates/bevy_reflect/src/serde/ser/tuple_structs.rs index 625e41e116..388cdebe57 100644 --- a/crates/bevy_reflect/src/serde/ser/tuple_structs.rs +++ b/crates/bevy_reflect/src/serde/ser/tuple_structs.rs @@ -1,8 +1,8 @@ -use crate::serde::ser::error_utils::make_custom_error; -use crate::serde::{SerializationData, TypedReflectSerializer}; -use crate::{TupleStruct, TypeInfo, TypeRegistry}; -use serde::ser::SerializeTupleStruct; -use serde::Serialize; +use crate::{ + serde::{ser::error_utils::make_custom_error, SerializationData, TypedReflectSerializer}, + TupleStruct, TypeInfo, TypeRegistry, +}; +use serde::{ser::SerializeTupleStruct, Serialize}; /// A serializer for [`TupleStruct`] values. pub(super) struct TupleStructSerializer<'a> { diff --git a/crates/bevy_reflect/src/serde/ser/tuples.rs b/crates/bevy_reflect/src/serde/ser/tuples.rs index e106149613..133818dfa9 100644 --- a/crates/bevy_reflect/src/serde/ser/tuples.rs +++ b/crates/bevy_reflect/src/serde/ser/tuples.rs @@ -1,7 +1,5 @@ -use crate::serde::TypedReflectSerializer; -use crate::{Tuple, TypeRegistry}; -use serde::ser::SerializeTuple; -use serde::Serialize; +use crate::{serde::TypedReflectSerializer, Tuple, TypeRegistry}; +use serde::{ser::SerializeTuple, Serialize}; /// A serializer for [`Tuple`] values. pub(super) struct TupleSerializer<'a> { diff --git a/crates/bevy_reflect/src/serde/type_data.rs b/crates/bevy_reflect/src/serde/type_data.rs index 66dc9c8237..35366b3909 100644 --- a/crates/bevy_reflect/src/serde/type_data.rs +++ b/crates/bevy_reflect/src/serde/type_data.rs @@ -1,6 +1,5 @@ use crate::Reflect; -use bevy_utils::hashbrown::hash_map::Iter; -use bevy_utils::HashMap; +use bevy_utils::{hashbrown::hash_map::Iter, HashMap}; /// Contains data relevant to the automatic reflect powered (de)serialization of a type. #[derive(Debug, Clone)] diff --git a/crates/bevy_reflect/src/set.rs b/crates/bevy_reflect/src/set.rs index 101ed23bb2..49d3a09e30 100644 --- a/crates/bevy_reflect/src/set.rs +++ b/crates/bevy_reflect/src/set.rs @@ -1,13 +1,11 @@ use std::fmt::{Debug, Formatter}; use bevy_reflect_derive::impl_type_path; -use bevy_utils::hashbrown::hash_table::OccupiedEntry as HashTableOccupiedEntry; -use bevy_utils::hashbrown::HashTable; +use bevy_utils::hashbrown::{hash_table::OccupiedEntry as HashTableOccupiedEntry, HashTable}; -use crate::type_info::impl_type_methods; use crate::{ - self as bevy_reflect, hash_error, ApplyError, PartialReflect, Reflect, ReflectKind, ReflectMut, - ReflectOwned, ReflectRef, Type, TypeInfo, TypePath, + self as bevy_reflect, hash_error, type_info::impl_type_methods, ApplyError, PartialReflect, + Reflect, ReflectKind, ReflectMut, ReflectOwned, ReflectRef, Type, TypeInfo, TypePath, }; /// A trait used to power [set-like] operations via [reflection]. diff --git a/crates/bevy_reflect/src/struct_trait.rs b/crates/bevy_reflect/src/struct_trait.rs index 9b399fcf82..1d571d8b45 100644 --- a/crates/bevy_reflect/src/struct_trait.rs +++ b/crates/bevy_reflect/src/struct_trait.rs @@ -1,14 +1,18 @@ -use crate::attributes::{impl_custom_attribute_methods, CustomAttributes}; -use crate::type_info::impl_type_methods; use crate::{ - self as bevy_reflect, ApplyError, NamedField, PartialReflect, Reflect, ReflectKind, ReflectMut, - ReflectOwned, ReflectRef, Type, TypeInfo, TypePath, + self as bevy_reflect, + attributes::{impl_custom_attribute_methods, CustomAttributes}, + type_info::impl_type_methods, + ApplyError, NamedField, PartialReflect, Reflect, ReflectKind, ReflectMut, ReflectOwned, + ReflectRef, Type, TypeInfo, TypePath, }; use bevy_reflect_derive::impl_type_path; use bevy_utils::HashMap; -use std::fmt::{Debug, Formatter}; -use std::sync::Arc; -use std::{borrow::Cow, slice::Iter}; +use std::{ + borrow::Cow, + fmt::{Debug, Formatter}, + slice::Iter, + sync::Arc, +}; /// A trait used to power [struct-like] operations via [reflection]. /// @@ -90,7 +94,6 @@ impl StructInfo { /// # Arguments /// /// * `fields`: The fields of this struct in the order they are defined - /// pub fn new(fields: &[NamedField]) -> Self { let field_indices = fields .iter() diff --git a/crates/bevy_reflect/src/tuple.rs b/crates/bevy_reflect/src/tuple.rs index 8ed85c67de..5aabdb67b2 100644 --- a/crates/bevy_reflect/src/tuple.rs +++ b/crates/bevy_reflect/src/tuple.rs @@ -1,16 +1,17 @@ use bevy_reflect_derive::impl_type_path; use bevy_utils::all_tuples; -use crate::type_info::impl_type_methods; use crate::{ - self as bevy_reflect, utility::GenericTypePathCell, ApplyError, FromReflect, - GetTypeRegistration, MaybeTyped, Reflect, ReflectMut, ReflectOwned, ReflectRef, Type, TypeInfo, - TypePath, TypeRegistration, TypeRegistry, Typed, UnnamedField, + self as bevy_reflect, type_info::impl_type_methods, utility::GenericTypePathCell, ApplyError, + FromReflect, GetTypeRegistration, MaybeTyped, PartialReflect, Reflect, ReflectKind, ReflectMut, + ReflectOwned, ReflectRef, Type, TypeInfo, TypePath, TypeRegistration, TypeRegistry, Typed, + UnnamedField, +}; +use std::{ + any::Any, + fmt::{Debug, Formatter}, + slice::Iter, }; -use crate::{PartialReflect, ReflectKind}; -use std::any::Any; -use std::fmt::{Debug, Formatter}; -use std::slice::Iter; /// A trait used to power [tuple-like] operations via [reflection]. /// @@ -152,7 +153,6 @@ impl TupleInfo { /// # Arguments /// /// * `fields`: The fields of this tuple in the order they are defined - /// pub fn new(fields: &[UnnamedField]) -> Self { Self { ty: Type::of::(), diff --git a/crates/bevy_reflect/src/tuple_struct.rs b/crates/bevy_reflect/src/tuple_struct.rs index 2acc1602b2..ccf4a716e1 100644 --- a/crates/bevy_reflect/src/tuple_struct.rs +++ b/crates/bevy_reflect/src/tuple_struct.rs @@ -1,14 +1,17 @@ use bevy_reflect_derive::impl_type_path; -use crate::attributes::{impl_custom_attribute_methods, CustomAttributes}; -use crate::type_info::impl_type_methods; use crate::{ - self as bevy_reflect, ApplyError, DynamicTuple, PartialReflect, Reflect, ReflectKind, - ReflectMut, ReflectOwned, ReflectRef, Tuple, Type, TypeInfo, TypePath, UnnamedField, + self as bevy_reflect, + attributes::{impl_custom_attribute_methods, CustomAttributes}, + type_info::impl_type_methods, + ApplyError, DynamicTuple, PartialReflect, Reflect, ReflectKind, ReflectMut, ReflectOwned, + ReflectRef, Tuple, Type, TypeInfo, TypePath, UnnamedField, +}; +use std::{ + fmt::{Debug, Formatter}, + slice::Iter, + sync::Arc, }; -use std::fmt::{Debug, Formatter}; -use std::slice::Iter; -use std::sync::Arc; /// A trait used to power [tuple struct-like] operations via [reflection]. /// @@ -71,7 +74,6 @@ impl TupleStructInfo { /// # Arguments /// /// * `fields`: The fields of this struct in the order they are defined - /// pub fn new(fields: &[UnnamedField]) -> Self { Self { ty: Type::of::(), diff --git a/crates/bevy_reflect/src/type_info.rs b/crates/bevy_reflect/src/type_info.rs index d667dda3bb..8cfc23814e 100644 --- a/crates/bevy_reflect/src/type_info.rs +++ b/crates/bevy_reflect/src/type_info.rs @@ -4,9 +4,11 @@ use crate::{ StructInfo, TupleInfo, TupleStructInfo, TypePath, TypePathTable, }; use core::fmt::Formatter; -use std::any::{Any, TypeId}; -use std::fmt::Debug; -use std::hash::Hash; +use std::{ + any::{Any, TypeId}, + fmt::Debug, + hash::Hash, +}; use thiserror::Error; /// A static accessor to compile-time type information. diff --git a/crates/bevy_reflect/src/type_info_stack.rs b/crates/bevy_reflect/src/type_info_stack.rs index f7f22a54ac..c2806553dd 100644 --- a/crates/bevy_reflect/src/type_info_stack.rs +++ b/crates/bevy_reflect/src/type_info_stack.rs @@ -1,6 +1,8 @@ use crate::TypeInfo; -use core::fmt::{Debug, Formatter}; -use core::slice::Iter; +use core::{ + fmt::{Debug, Formatter}, + slice::Iter, +}; /// Helper struct for managing a stack of [`TypeInfo`] instances. /// diff --git a/crates/bevy_reflect/src/type_registry.rs b/crates/bevy_reflect/src/type_registry.rs index 849d8279b9..dfcdf1b4f9 100644 --- a/crates/bevy_reflect/src/type_registry.rs +++ b/crates/bevy_reflect/src/type_registry.rs @@ -3,10 +3,10 @@ use bevy_ptr::{Ptr, PtrMut}; use bevy_utils::{HashMap, HashSet, TypeIdMap}; use downcast_rs::{impl_downcast, Downcast}; use serde::Deserialize; -use std::ops::{Deref, DerefMut}; use std::{ any::TypeId, fmt::Debug, + ops::{Deref, DerefMut}, sync::{Arc, PoisonError, RwLock, RwLockReadGuard, RwLockWriteGuard}, }; @@ -279,7 +279,6 @@ impl TypeRegistry { /// given [`TypeId`]. /// /// If the specified type has not been registered, returns `None`. - /// #[inline] pub fn get(&self, type_id: TypeId) -> Option<&TypeRegistration> { self.registrations.get(&type_id) @@ -289,7 +288,6 @@ impl TypeRegistry { /// the given [`TypeId`]. /// /// If the specified type has not been registered, returns `None`. - /// pub fn get_mut(&mut self, type_id: TypeId) -> Option<&mut TypeRegistration> { self.registrations.get_mut(&type_id) } diff --git a/crates/bevy_remote/src/builtin_methods.rs b/crates/bevy_remote/src/builtin_methods.rs index d6ca798dad..705b7600d0 100644 --- a/crates/bevy_remote/src/builtin_methods.rs +++ b/crates/bevy_remote/src/builtin_methods.rs @@ -17,8 +17,7 @@ use bevy_reflect::{ PartialReflect, TypeRegistration, TypeRegistry, }; use bevy_utils::HashMap; -use serde::de::DeserializeSeed as _; -use serde::{Deserialize, Serialize}; +use serde::{de::DeserializeSeed as _, Deserialize, Serialize}; use serde_json::Value; use crate::{error_codes, BrpError, BrpResult}; diff --git a/crates/bevy_remote/src/lib.rs b/crates/bevy_remote/src/lib.rs index 1f9b8d0695..7b14b59f9e 100644 --- a/crates/bevy_remote/src/lib.rs +++ b/crates/bevy_remote/src/lib.rs @@ -291,6 +291,7 @@ pub const DEFAULT_ADDR: IpAddr = IpAddr::V4(Ipv4Addr::new(127, 0, 0, 1)); const CHANNEL_SIZE: usize = 16; /// Add this plugin to your [`App`] to allow remote connections to inspect and modify entities. +/// /// This the main plugin for `bevy_remote`. See the [crate-level documentation] for details on /// the protocol and its default methods. /// diff --git a/crates/bevy_render/macros/src/as_bind_group.rs b/crates/bevy_render/macros/src/as_bind_group.rs index 6de62672a6..d0edd18dd6 100644 --- a/crates/bevy_render/macros/src/as_bind_group.rs +++ b/crates/bevy_render/macros/src/as_bind_group.rs @@ -1109,7 +1109,7 @@ fn get_storage_binding_attr(metas: Vec) -> Result { let mut buffer = false; for meta in metas { - use syn::{Meta::List, Meta::Path}; + use syn::Meta::{List, Path}; match meta { // Parse #[storage(0, visibility(...))]. List(m) if m.path == VISIBILITY => { diff --git a/crates/bevy_render/macros/src/lib.rs b/crates/bevy_render/macros/src/lib.rs index 6d837fb095..d7cb909477 100644 --- a/crates/bevy_render/macros/src/lib.rs +++ b/crates/bevy_render/macros/src/lib.rs @@ -24,6 +24,7 @@ pub fn derive_extract_resource(input: TokenStream) -> TokenStream { } /// Implements `ExtractComponent` trait for a component. +/// /// The component must implement [`Clone`]. /// The component will be extracted into the render world via cloning. /// Note that this only enables extraction of the component, it does not execute the extraction. diff --git a/crates/bevy_render/src/alpha.rs b/crates/bevy_render/src/alpha.rs index 13a4943c10..12e1377eab 100644 --- a/crates/bevy_render/src/alpha.rs +++ b/crates/bevy_render/src/alpha.rs @@ -1,5 +1,4 @@ -use bevy_reflect::std_traits::ReflectDefault; -use bevy_reflect::Reflect; +use bevy_reflect::{std_traits::ReflectDefault, Reflect}; // TODO: add discussion about performance. /// Sets how a material's base color alpha channel is used for transparency. diff --git a/crates/bevy_render/src/camera/camera.rs b/crates/bevy_render/src/camera/camera.rs index f58f75aaf8..1964b49562 100644 --- a/crates/bevy_render/src/camera/camera.rs +++ b/crates/bevy_render/src/camera/camera.rs @@ -28,8 +28,7 @@ use bevy_math::{ops, vec2, Dir3, Mat4, Ray3d, Rect, URect, UVec2, UVec4, Vec2, V use bevy_reflect::prelude::*; use bevy_render_macros::ExtractComponent; use bevy_transform::components::GlobalTransform; -use bevy_utils::{tracing::warn, warn_once}; -use bevy_utils::{HashMap, HashSet}; +use bevy_utils::{tracing::warn, warn_once, HashMap, HashSet}; use bevy_window::{ NormalizedWindowRef, PrimaryWindow, Window, WindowCreated, WindowRef, WindowResized, WindowScaleFactorChanged, diff --git a/crates/bevy_render/src/camera/manual_texture_view.rs b/crates/bevy_render/src/camera/manual_texture_view.rs index 1672bcf399..927e27bab6 100644 --- a/crates/bevy_render/src/camera/manual_texture_view.rs +++ b/crates/bevy_render/src/camera/manual_texture_view.rs @@ -1,8 +1,7 @@ -use crate::extract_resource::ExtractResource; -use crate::render_resource::TextureView; -use crate::texture::BevyDefault; -use bevy_ecs::system::Resource; -use bevy_ecs::{prelude::Component, reflect::ReflectComponent}; +use crate::{ + extract_resource::ExtractResource, render_resource::TextureView, texture::BevyDefault, +}; +use bevy_ecs::{prelude::Component, reflect::ReflectComponent, system::Resource}; use bevy_math::UVec2; use bevy_reflect::prelude::*; use bevy_utils::HashMap; diff --git a/crates/bevy_render/src/camera/projection.rs b/crates/bevy_render/src/camera/projection.rs index 3a08506f37..addeed4b0d 100644 --- a/crates/bevy_render/src/camera/projection.rs +++ b/crates/bevy_render/src/camera/projection.rs @@ -1,16 +1,16 @@ -use std::marker::PhantomData; -use std::ops::{Div, DivAssign, Mul, MulAssign}; +use std::{ + marker::PhantomData, + ops::{Div, DivAssign, Mul, MulAssign}, +}; -use crate::primitives::Frustum; -use crate::view::VisibilitySystems; +use crate::{primitives::Frustum, view::VisibilitySystems}; use bevy_app::{App, Plugin, PostStartup, PostUpdate}; use bevy_ecs::prelude::*; use bevy_math::{ops, AspectRatio, Mat4, Rect, Vec2, Vec3A}; use bevy_reflect::{ std_traits::ReflectDefault, GetTypeRegistration, Reflect, ReflectDeserialize, ReflectSerialize, }; -use bevy_transform::components::GlobalTransform; -use bevy_transform::TransformSystem; +use bevy_transform::{components::GlobalTransform, TransformSystem}; use serde::{Deserialize, Serialize}; /// Adds [`Camera`](crate::camera::Camera) driver systems for a given projection type. diff --git a/crates/bevy_render/src/lib.rs b/crates/bevy_render/src/lib.rs index e6c35f0783..1c2b7658e1 100644 --- a/crates/bevy_render/src/lib.rs +++ b/crates/bevy_render/src/lib.rs @@ -71,14 +71,12 @@ use globals::GlobalsPlugin; use render_asset::RenderAssetBytesPerFrame; use renderer::{RenderAdapter, RenderAdapterInfo, RenderDevice, RenderQueue}; -use crate::mesh::RenderMesh; -use crate::renderer::WgpuWrapper; use crate::{ camera::CameraPlugin, - mesh::{morph::MorphPlugin, MeshPlugin}, + mesh::{morph::MorphPlugin, MeshPlugin, RenderMesh}, render_asset::prepare_assets, render_resource::{PipelineCache, Shader, ShaderLoader}, - renderer::{render_system, RenderInstance}, + renderer::{render_system, RenderInstance, WgpuWrapper}, settings::RenderCreation, storage::StoragePlugin, view::{ViewPlugin, WindowRenderPlugin}, @@ -203,6 +201,7 @@ impl Render { pub struct ExtractSchedule; /// The simulation [`World`] of the application, stored as a resource. +/// /// This resource is only available during [`ExtractSchedule`] and not /// during command application of that schedule. /// See [`Extract`] for more details. diff --git a/crates/bevy_render/src/pipelined_rendering.rs b/crates/bevy_render/src/pipelined_rendering.rs index b0db039896..7abca12845 100644 --- a/crates/bevy_render/src/pipelined_rendering.rs +++ b/crates/bevy_render/src/pipelined_rendering.rs @@ -66,6 +66,7 @@ impl Drop for RenderAppChannels { } /// The [`PipelinedRenderingPlugin`] can be added to your application to enable pipelined rendering. +/// /// This moves rendering into a different thread, so that the Nth frame's rendering can /// be run at the same time as the N + 1 frame's simulation. /// diff --git a/crates/bevy_render/src/primitives/mod.rs b/crates/bevy_render/src/primitives/mod.rs index 476e4740ec..b1d2ead40c 100644 --- a/crates/bevy_render/src/primitives/mod.rs +++ b/crates/bevy_render/src/primitives/mod.rs @@ -127,6 +127,7 @@ impl Sphere { } /// A region of 3D space, specifically an open set whose border is a bisecting 2D plane. +/// /// This bisecting plane partitions 3D space into two infinite regions, /// the half-space is one of those regions and excludes the bisecting plane. /// diff --git a/crates/bevy_render/src/render_graph/graph.rs b/crates/bevy_render/src/render_graph/graph.rs index 9779e4a75c..d8af4d9289 100644 --- a/crates/bevy_render/src/render_graph/graph.rs +++ b/crates/bevy_render/src/render_graph/graph.rs @@ -23,6 +23,7 @@ define_label!( pub type InternedRenderSubGraph = Interned; /// The render graph configures the modular and re-usable render logic. +/// /// It is a retained and stateless (nodes themselves may have their own internal state) structure, /// which can not be modified while it is executed by the graph runner. /// diff --git a/crates/bevy_render/src/render_resource/bind_group.rs b/crates/bevy_render/src/render_resource/bind_group.rs index cb3a6fb347..0ecca1e431 100644 --- a/crates/bevy_render/src/render_resource/bind_group.rs +++ b/crates/bevy_render/src/render_resource/bind_group.rs @@ -396,6 +396,7 @@ impl OwnedBindingResource { } /// Converts a value to a [`ShaderType`] for use in a bind group. +/// /// This is automatically implemented for references that implement [`Into`]. /// Generally normal [`Into`] / [`From`] impls should be preferred, but /// sometimes additional runtime metadata is required. diff --git a/crates/bevy_render/src/render_resource/pipeline_cache.rs b/crates/bevy_render/src/render_resource/pipeline_cache.rs index 0c25d358d5..af33e9302b 100644 --- a/crates/bevy_render/src/render_resource/pipeline_cache.rs +++ b/crates/bevy_render/src/render_resource/pipeline_cache.rs @@ -4,12 +4,14 @@ use crate::{ Extract, }; use bevy_asset::{AssetEvent, AssetId, Assets}; -use bevy_ecs::system::{Res, ResMut}; -use bevy_ecs::{event::EventReader, system::Resource}; +use bevy_ecs::{ + event::EventReader, + system::{Res, ResMut, Resource}, +}; use bevy_tasks::Task; -use bevy_utils::hashbrown::hash_map::EntryRef; use bevy_utils::{ default, + hashbrown::hash_map::EntryRef, tracing::{debug, error}, HashMap, HashSet, }; diff --git a/crates/bevy_render/src/render_resource/pipeline_specializer.rs b/crates/bevy_render/src/render_resource/pipeline_specializer.rs index 93c4b236c6..5f9455aa5f 100644 --- a/crates/bevy_render/src/render_resource/pipeline_specializer.rs +++ b/crates/bevy_render/src/render_resource/pipeline_specializer.rs @@ -1,15 +1,17 @@ -use crate::mesh::MeshVertexBufferLayoutRef; -use crate::render_resource::CachedComputePipelineId; use crate::{ - mesh::MissingVertexAttributeError, + mesh::{MeshVertexBufferLayoutRef, MissingVertexAttributeError}, render_resource::{ - CachedRenderPipelineId, ComputePipelineDescriptor, PipelineCache, RenderPipelineDescriptor, - VertexBufferLayout, + CachedComputePipelineId, CachedRenderPipelineId, ComputePipelineDescriptor, PipelineCache, + RenderPipelineDescriptor, VertexBufferLayout, }, }; use bevy_ecs::system::Resource; -use bevy_utils::hashbrown::hash_map::VacantEntry; -use bevy_utils::{default, hashbrown::hash_map::RawEntryMut, tracing::error, Entry, HashMap}; +use bevy_utils::{ + default, + hashbrown::hash_map::{RawEntryMut, VacantEntry}, + tracing::error, + Entry, HashMap, +}; use std::{fmt::Debug, hash::Hash}; use thiserror::Error; diff --git a/crates/bevy_render/src/renderer/mod.rs b/crates/bevy_render/src/renderer/mod.rs index 582ad2d181..50afc95c62 100644 --- a/crates/bevy_render/src/renderer/mod.rs +++ b/crates/bevy_render/src/renderer/mod.rs @@ -119,6 +119,7 @@ pub fn render_system(world: &mut World, state: &mut SystemState DynamicSceneBuilder<'w> { #[cfg(test)] mod tests { use bevy_ecs::{ - component::Component, prelude::Entity, prelude::Resource, query::With, - reflect::AppTypeRegistry, reflect::ReflectComponent, reflect::ReflectResource, + component::Component, + prelude::{Entity, Resource}, + query::With, + reflect::{AppTypeRegistry, ReflectComponent, ReflectResource}, world::World, }; diff --git a/crates/bevy_scene/src/scene.rs b/crates/bevy_scene/src/scene.rs index f852d356b3..5d0cf57639 100644 --- a/crates/bevy_scene/src/scene.rs +++ b/crates/bevy_scene/src/scene.rs @@ -1,7 +1,7 @@ use crate::{DynamicScene, SceneSpawnError}; use bevy_asset::Asset; -use bevy_ecs::entity::{Entity, EntityHashMap}; use bevy_ecs::{ + entity::{Entity, EntityHashMap}, reflect::{AppTypeRegistry, ReflectComponent, ReflectMapEntities, ReflectResource}, world::World, }; diff --git a/crates/bevy_scene/src/scene_filter.rs b/crates/bevy_scene/src/scene_filter.rs index 1bdfdfa871..01811cb9fd 100644 --- a/crates/bevy_scene/src/scene_filter.rs +++ b/crates/bevy_scene/src/scene_filter.rs @@ -1,5 +1,4 @@ -use bevy_utils::hashbrown::hash_set::IntoIter; -use bevy_utils::HashSet; +use bevy_utils::{hashbrown::hash_set::IntoIter, HashSet}; use std::any::{Any, TypeId}; /// A filter used to control which types can be added to a [`DynamicScene`]. diff --git a/crates/bevy_scene/src/scene_loader.rs b/crates/bevy_scene/src/scene_loader.rs index 566a573560..200fb2d7ea 100644 --- a/crates/bevy_scene/src/scene_loader.rs +++ b/crates/bevy_scene/src/scene_loader.rs @@ -1,10 +1,11 @@ -use crate::ron; #[cfg(feature = "serialize")] use crate::serde::SceneDeserializer; -use crate::DynamicScene; +use crate::{ron, DynamicScene}; use bevy_asset::{io::Reader, AssetLoader, LoadContext}; -use bevy_ecs::reflect::AppTypeRegistry; -use bevy_ecs::world::{FromWorld, World}; +use bevy_ecs::{ + reflect::AppTypeRegistry, + world::{FromWorld, World}, +}; use bevy_reflect::TypeRegistryArc; #[cfg(feature = "serialize")] use serde::de::DeserializeSeed; diff --git a/crates/bevy_scene/src/scene_spawner.rs b/crates/bevy_scene/src/scene_spawner.rs index fb3fa62466..186b38a422 100644 --- a/crates/bevy_scene/src/scene_spawner.rs +++ b/crates/bevy_scene/src/scene_spawner.rs @@ -1,8 +1,7 @@ use crate::{DynamicScene, Scene}; use bevy_asset::{AssetEvent, AssetId, Assets, Handle}; -use bevy_ecs::entity::EntityHashMap; use bevy_ecs::{ - entity::Entity, + entity::{Entity, EntityHashMap}, event::{Event, EventCursor, Events}, reflect::AppTypeRegistry, system::Resource, @@ -473,13 +472,14 @@ pub fn scene_spawner_system(world: &mut World) { #[cfg(test)] mod tests { use bevy_app::App; - use bevy_asset::Handle; - use bevy_asset::{AssetPlugin, AssetServer}; - use bevy_ecs::observer::Trigger; - use bevy_ecs::prelude::ReflectComponent; - use bevy_ecs::query::With; - use bevy_ecs::system::{Commands, Res, ResMut, RunSystemOnce}; - use bevy_ecs::{component::Component, system::Query}; + use bevy_asset::{AssetPlugin, AssetServer, Handle}; + use bevy_ecs::{ + component::Component, + observer::Trigger, + prelude::ReflectComponent, + query::With, + system::{Commands, Query, Res, ResMut, RunSystemOnce}, + }; use bevy_reflect::Reflect; use crate::{DynamicSceneBuilder, ScenePlugin}; diff --git a/crates/bevy_scene/src/serde.rs b/crates/bevy_scene/src/serde.rs index bbf5735018..67608d98b5 100644 --- a/crates/bevy_scene/src/serde.rs +++ b/crates/bevy_scene/src/serde.rs @@ -2,17 +2,17 @@ use crate::{DynamicEntity, DynamicScene}; use bevy_ecs::entity::Entity; -use bevy_reflect::serde::{TypedReflectDeserializer, TypedReflectSerializer}; use bevy_reflect::{ - serde::{ReflectDeserializer, TypeRegistrationDeserializer}, - TypeRegistry, + serde::{ + ReflectDeserializer, TypeRegistrationDeserializer, TypedReflectDeserializer, + TypedReflectSerializer, + }, + PartialReflect, ReflectFromReflect, TypeRegistry, }; -use bevy_reflect::{PartialReflect, ReflectFromReflect}; use bevy_utils::HashSet; -use serde::ser::SerializeMap; use serde::{ de::{DeserializeSeed, Error, MapAccess, SeqAccess, Visitor}, - ser::SerializeStruct, + ser::{SerializeMap, SerializeStruct}, Deserialize, Deserializer, Serialize, Serializer, }; use std::fmt::Formatter; @@ -509,19 +509,21 @@ impl<'a, 'de> Visitor<'de> for SceneMapVisitor<'a> { #[cfg(test)] mod tests { - use crate::ron; - use crate::serde::{SceneDeserializer, SceneSerializer}; - use crate::{DynamicScene, DynamicSceneBuilder}; - use bevy_ecs::entity::EntityHashMap; - use bevy_ecs::entity::{Entity, EntityMapper, MapEntities}; - use bevy_ecs::prelude::{Component, ReflectComponent, ReflectResource, Resource, World}; - use bevy_ecs::query::{With, Without}; - use bevy_ecs::reflect::{AppTypeRegistry, ReflectMapEntities}; - use bevy_ecs::world::FromWorld; + use crate::{ + ron, + serde::{SceneDeserializer, SceneSerializer}, + DynamicScene, DynamicSceneBuilder, + }; + use bevy_ecs::{ + entity::{Entity, EntityHashMap, EntityMapper, MapEntities}, + prelude::{Component, ReflectComponent, ReflectResource, Resource, World}, + query::{With, Without}, + reflect::{AppTypeRegistry, ReflectMapEntities}, + world::FromWorld, + }; use bevy_reflect::{Reflect, ReflectDeserialize, ReflectSerialize}; use bincode::Options; - use serde::de::DeserializeSeed; - use serde::{Deserialize, Serialize}; + use serde::{de::DeserializeSeed, Deserialize, Serialize}; use std::io::BufReader; #[derive(Component, Reflect, Default)] diff --git a/crates/bevy_sprite/src/mesh2d/mesh.rs b/crates/bevy_sprite/src/mesh2d/mesh.rs index 7ef45ec298..0f70232afc 100644 --- a/crates/bevy_sprite/src/mesh2d/mesh.rs +++ b/crates/bevy_sprite/src/mesh2d/mesh.rs @@ -16,26 +16,26 @@ use bevy_ecs::{ }; use bevy_math::{Affine3, Vec4}; use bevy_reflect::{std_traits::ReflectDefault, Reflect}; -use bevy_render::batching::gpu_preprocessing::IndirectParameters; -use bevy_render::batching::no_gpu_preprocessing::batch_and_prepare_binned_render_phase; -use bevy_render::batching::no_gpu_preprocessing::{ - self, batch_and_prepare_sorted_render_phase, write_batched_instance_buffer, - BatchedInstanceBuffer, -}; -use bevy_render::batching::GetFullBatchData; -use bevy_render::mesh::allocator::MeshAllocator; -use bevy_render::mesh::{MeshVertexBufferLayoutRef, RenderMesh}; -use bevy_render::texture::FallbackImage; use bevy_render::{ - batching::{GetBatchData, NoAutomaticBatching}, + batching::{ + gpu_preprocessing::IndirectParameters, + no_gpu_preprocessing::{ + self, batch_and_prepare_binned_render_phase, batch_and_prepare_sorted_render_phase, + write_batched_instance_buffer, BatchedInstanceBuffer, + }, + GetBatchData, GetFullBatchData, NoAutomaticBatching, + }, globals::{GlobalsBuffer, GlobalsUniform}, - mesh::{Mesh, RenderMeshBufferInfo}, + mesh::{ + allocator::MeshAllocator, Mesh, MeshVertexBufferLayoutRef, RenderMesh, RenderMeshBufferInfo, + }, render_asset::RenderAssets, render_phase::{PhaseItem, RenderCommand, RenderCommandResult, TrackedRenderPass}, render_resource::{binding_types::uniform_buffer, *}, renderer::{RenderDevice, RenderQueue}, texture::{ - BevyDefault, DefaultImageSampler, GpuImage, Image, ImageSampler, TextureFormatPixelInfo, + BevyDefault, DefaultImageSampler, FallbackImage, GpuImage, Image, ImageSampler, + TextureFormatPixelInfo, }, view::{ ExtractedView, ViewTarget, ViewUniform, ViewUniformOffset, ViewUniforms, ViewVisibility, diff --git a/crates/bevy_sprite/src/mesh2d/wireframe2d.rs b/crates/bevy_sprite/src/mesh2d/wireframe2d.rs index 83af6c3ed9..a8822c800e 100644 --- a/crates/bevy_sprite/src/mesh2d/wireframe2d.rs +++ b/crates/bevy_sprite/src/mesh2d/wireframe2d.rs @@ -60,6 +60,7 @@ impl Plugin for Wireframe2dPlugin { pub struct Wireframe2d; /// Sets the color of the [`Wireframe2d`] of the entity it is attached to. +/// /// If this component is present but there's no [`Wireframe2d`] component, /// it will still affect the color of the wireframe when [`Wireframe2dConfig::global`] is set to true. /// diff --git a/crates/bevy_sprite/src/render/mod.rs b/crates/bevy_sprite/src/render/mod.rs index 60c64131fe..f4490d76e4 100644 --- a/crates/bevy_sprite/src/render/mod.rs +++ b/crates/bevy_sprite/src/render/mod.rs @@ -13,9 +13,10 @@ use bevy_core_pipeline::{ TonemappingLuts, }, }; -use bevy_ecs::{entity::EntityHashMap, query::ROQueryItem}; use bevy_ecs::{ + entity::EntityHashMap, prelude::*, + query::ROQueryItem, system::{lifetimeless::*, SystemParamItem, SystemState}, }; use bevy_math::{Affine3A, FloatOrd, Quat, Rect, Vec2, Vec4}; diff --git a/crates/bevy_sprite/src/texture_atlas.rs b/crates/bevy_sprite/src/texture_atlas.rs index 70e10e5914..a22cbe8e91 100644 --- a/crates/bevy_sprite/src/texture_atlas.rs +++ b/crates/bevy_sprite/src/texture_atlas.rs @@ -1,9 +1,7 @@ use bevy_asset::{Asset, AssetId, Assets, Handle}; -use bevy_ecs::component::Component; -use bevy_ecs::reflect::ReflectComponent; +use bevy_ecs::{component::Component, reflect::ReflectComponent}; use bevy_math::{URect, UVec2}; -use bevy_reflect::std_traits::ReflectDefault; -use bevy_reflect::Reflect; +use bevy_reflect::{std_traits::ReflectDefault, Reflect}; use bevy_render::texture::Image; use bevy_utils::HashMap; diff --git a/crates/bevy_sprite/src/texture_atlas_builder.rs b/crates/bevy_sprite/src/texture_atlas_builder.rs index e000516a7d..01d84549bb 100644 --- a/crates/bevy_sprite/src/texture_atlas_builder.rs +++ b/crates/bevy_sprite/src/texture_atlas_builder.rs @@ -5,8 +5,10 @@ use bevy_render::{ render_resource::{Extent3d, TextureDimension, TextureFormat}, texture::{Image, TextureFormatPixelInfo}, }; -use bevy_utils::tracing::{debug, error, warn}; -use bevy_utils::HashMap; +use bevy_utils::{ + tracing::{debug, error, warn}, + HashMap, +}; use rectangle_pack::{ contains_smallest_box, pack_rects, volume_heuristic, GroupedRectsToPlace, PackedLocation, RectToInsert, TargetBin, diff --git a/crates/bevy_sprite/src/texture_slice/slicer.rs b/crates/bevy_sprite/src/texture_slice/slicer.rs index b290272edd..ea32f1122b 100644 --- a/crates/bevy_sprite/src/texture_slice/slicer.rs +++ b/crates/bevy_sprite/src/texture_slice/slicer.rs @@ -210,9 +210,7 @@ impl TextureSlicer { /// /// * `rect` - The section of the texture to slice in 9 parts /// * `render_size` - The optional draw size of the texture. If not set the `rect` size will be used. - // // TODO: Support `URect` and `UVec2` instead (See `https://github.com/bevyengine/bevy/pull/11698`) - // #[must_use] pub fn compute_slices(&self, rect: Rect, render_size: Option) -> Vec { let render_size = render_size.unwrap_or_else(|| rect.size()); @@ -390,7 +388,7 @@ mod test { } ); assert_eq!( - vertical_sides[0], /* top */ + vertical_sides[0], // top TextureSlice { texture_rect: Rect { min: Vec2::new(5.0, 0.0), diff --git a/crates/bevy_state/src/app.rs b/crates/bevy_state/src/app.rs index 4541a1cd5d..03df950980 100644 --- a/crates/bevy_state/src/app.rs +++ b/crates/bevy_state/src/app.rs @@ -2,11 +2,13 @@ use bevy_app::{App, MainScheduleOrder, Plugin, PreStartup, PreUpdate, SubApp}; use bevy_ecs::{event::Events, schedule::IntoSystemConfigs, world::FromWorld}; use bevy_utils::{tracing::warn, warn_once}; -use crate::state::{ - setup_state_transitions_in_world, ComputedStates, FreelyMutableState, NextState, State, - StateTransition, StateTransitionEvent, StateTransitionSteps, States, SubStates, +use crate::{ + state::{ + setup_state_transitions_in_world, ComputedStates, FreelyMutableState, NextState, State, + StateTransition, StateTransitionEvent, StateTransitionSteps, States, SubStates, + }, + state_scoped::clear_state_scoped_entities, }; -use crate::state_scoped::clear_state_scoped_entities; #[cfg(feature = "bevy_reflect")] use bevy_reflect::{FromReflect, GetTypeRegistration, Typed}; diff --git a/crates/bevy_state/src/reflect.rs b/crates/bevy_state/src/reflect.rs index 422d4aff1a..5213681a79 100644 --- a/crates/bevy_state/src/reflect.rs +++ b/crates/bevy_state/src/reflect.rs @@ -1,7 +1,6 @@ use crate::state::{FreelyMutableState, NextState, State, States}; -use bevy_ecs::reflect::from_reflect_with_fallback; -use bevy_ecs::world::World; +use bevy_ecs::{reflect::from_reflect_with_fallback, world::World}; use bevy_reflect::{FromType, Reflect, TypePath, TypeRegistry}; /// A struct used to operate on the reflected [`States`] trait of a type. @@ -100,9 +99,11 @@ impl FromType for ReflectFreelyMu #[cfg(test)] mod tests { use crate as bevy_state; - use crate::app::{AppExtStates, StatesPlugin}; - use crate::reflect::{ReflectFreelyMutableState, ReflectState}; - use crate::state::State; + use crate::{ + app::{AppExtStates, StatesPlugin}, + reflect::{ReflectFreelyMutableState, ReflectState}, + state::State, + }; use bevy_app::App; use bevy_ecs::prelude::AppTypeRegistry; use bevy_reflect::Reflect; diff --git a/crates/bevy_state/src/state/computed_states.rs b/crates/bevy_state/src/state/computed_states.rs index fda0f99d8c..b64ad1f4fc 100644 --- a/crates/bevy_state/src/state/computed_states.rs +++ b/crates/bevy_state/src/state/computed_states.rs @@ -1,10 +1,8 @@ -use std::fmt::Debug; -use std::hash::Hash; +use std::{fmt::Debug, hash::Hash}; use bevy_ecs::schedule::Schedule; -use super::state_set::StateSet; -use super::states::States; +use super::{state_set::StateSet, states::States}; /// A state whose value is automatically computed based on the values of other [`States`]. /// diff --git a/crates/bevy_state/src/state/freely_mutable_state.rs b/crates/bevy_state/src/state/freely_mutable_state.rs index f2b6dd0c21..2bc186ebe0 100644 --- a/crates/bevy_state/src/state/freely_mutable_state.rs +++ b/crates/bevy_state/src/state/freely_mutable_state.rs @@ -1,13 +1,11 @@ -use bevy_ecs::schedule::{IntoSystemConfigs, IntoSystemSetConfigs}; -use bevy_ecs::system::IntoSystem; use bevy_ecs::{ event::EventWriter, prelude::Schedule, - system::{Commands, ResMut}, + schedule::{IntoSystemConfigs, IntoSystemSetConfigs}, + system::{Commands, IntoSystem, ResMut}, }; -use super::{states::States, NextState, State}; -use super::{take_next_state, transitions::*}; +use super::{states::States, take_next_state, transitions::*, NextState, State}; /// This trait allows a state to be mutated directly using the [`NextState`](crate::state::NextState) resource. /// diff --git a/crates/bevy_state/src/state/mod.rs b/crates/bevy_state/src/state/mod.rs index 5e5ea005df..d02d3a32ed 100644 --- a/crates/bevy_state/src/state/mod.rs +++ b/crates/bevy_state/src/state/mod.rs @@ -17,10 +17,8 @@ pub use transitions::*; #[cfg(test)] mod tests { - use bevy_ecs::event::EventRegistry; - use bevy_ecs::prelude::*; - use bevy_state_macros::States; - use bevy_state_macros::SubStates; + use bevy_ecs::{event::EventRegistry, prelude::*}; + use bevy_state_macros::{States, SubStates}; use super::*; use crate as bevy_state; diff --git a/crates/bevy_tasks/src/single_threaded_task_pool.rs b/crates/bevy_tasks/src/single_threaded_task_pool.rs index 7022405cc2..795d077476 100644 --- a/crates/bevy_tasks/src/single_threaded_task_pool.rs +++ b/crates/bevy_tasks/src/single_threaded_task_pool.rs @@ -1,5 +1,4 @@ -use std::sync::Arc; -use std::{cell::RefCell, future::Future, marker::PhantomData, mem, rc::Rc}; +use std::{cell::RefCell, future::Future, marker::PhantomData, mem, rc::Rc, sync::Arc}; use crate::Task; diff --git a/crates/bevy_text/src/bounds.rs b/crates/bevy_text/src/bounds.rs index 2dc5a27a49..98d42e3a34 100644 --- a/crates/bevy_text/src/bounds.rs +++ b/crates/bevy_text/src/bounds.rs @@ -1,9 +1,9 @@ use bevy_ecs::{component::Component, reflect::ReflectComponent}; use bevy_math::Vec2; -use bevy_reflect::std_traits::ReflectDefault; -use bevy_reflect::Reflect; +use bevy_reflect::{std_traits::ReflectDefault, Reflect}; /// The maximum width and height of text. The text will wrap according to the specified size. +/// /// Characters out of the bounds after wrapping will be truncated. Text is aligned according to the /// specified [`JustifyText`](crate::text::JustifyText). /// diff --git a/crates/bevy_text/src/text.rs b/crates/bevy_text/src/text.rs index 0c84ab8a0f..a785bb51af 100644 --- a/crates/bevy_text/src/text.rs +++ b/crates/bevy_text/src/text.rs @@ -181,6 +181,7 @@ impl From for TextSection { } /// Describes the horizontal alignment of multiple lines of text relative to each other. +/// /// This only affects the internal positioning of the lines of text within a text entity and /// does not affect the text entity's position. /// diff --git a/crates/bevy_time/src/lib.rs b/crates/bevy_time/src/lib.rs index 794423b196..6e33dd2f63 100644 --- a/crates/bevy_time/src/lib.rs +++ b/crates/bevy_time/src/lib.rs @@ -31,10 +31,10 @@ pub mod prelude { } use bevy_app::{prelude::*, RunFixedMainLoop}; -use bevy_ecs::event::{ - event_update_system, signal_event_update_system, EventRegistry, ShouldUpdateEvents, +use bevy_ecs::{ + event::{event_update_system, signal_event_update_system, EventRegistry, ShouldUpdateEvents}, + prelude::*, }; -use bevy_ecs::prelude::*; use bevy_utils::{tracing::warn, Duration, Instant}; pub use crossbeam_channel::TrySendError; use crossbeam_channel::{Receiver, Sender}; diff --git a/crates/bevy_transform/src/systems.rs b/crates/bevy_transform/src/systems.rs index c1a1df0631..12b3e43251 100644 --- a/crates/bevy_transform/src/systems.rs +++ b/crates/bevy_transform/src/systems.rs @@ -186,13 +186,11 @@ unsafe fn propagate_recursive( #[cfg(test)] mod test { use bevy_app::prelude::*; - use bevy_ecs::prelude::*; - use bevy_ecs::world::CommandQueue; + use bevy_ecs::{prelude::*, world::CommandQueue}; use bevy_math::{vec3, Vec3}; use bevy_tasks::{ComputeTaskPool, TaskPool}; - use crate::bundles::TransformBundle; - use crate::systems::*; + use crate::{bundles::TransformBundle, systems::*}; use bevy_hierarchy::{BuildChildren, ChildBuild}; #[test] diff --git a/crates/bevy_ui/src/geometry.rs b/crates/bevy_ui/src/geometry.rs index bd0164bbcc..d208139aab 100644 --- a/crates/bevy_ui/src/geometry.rs +++ b/crates/bevy_ui/src/geometry.rs @@ -1,8 +1,6 @@ use bevy_math::Vec2; -use bevy_reflect::std_traits::ReflectDefault; -use bevy_reflect::Reflect; -use std::ops::Neg; -use std::ops::{Div, DivAssign, Mul, MulAssign}; +use bevy_reflect::{std_traits::ReflectDefault, Reflect}; +use std::ops::{Div, DivAssign, Mul, MulAssign, Neg}; use thiserror::Error; #[cfg(feature = "serialize")] @@ -207,7 +205,6 @@ impl Val { /// /// # Examples -/// /// ## Margin /// /// A margin is used to create space around UI elements, outside of any defined borders. diff --git a/crates/bevy_ui/src/layout/mod.rs b/crates/bevy_ui/src/layout/mod.rs index 43e7fa428f..5399e9a124 100644 --- a/crates/bevy_ui/src/layout/mod.rs +++ b/crates/bevy_ui/src/layout/mod.rs @@ -447,43 +447,43 @@ fn approx_round_layout_coords(value: Vec2) -> Vec2 { mod tests { use taffy::TraversePartialTree; - use bevy_asset::AssetEvent; - use bevy_asset::Assets; + use bevy_asset::{AssetEvent, Assets}; use bevy_core_pipeline::core_2d::Camera2dBundle; - use bevy_ecs::entity::Entity; - use bevy_ecs::event::Events; - use bevy_ecs::prelude::{Commands, Component, In, Query, With}; - use bevy_ecs::query::Without; - use bevy_ecs::schedule::apply_deferred; - use bevy_ecs::schedule::IntoSystemConfigs; - use bevy_ecs::schedule::Schedule; - use bevy_ecs::system::RunSystemOnce; - use bevy_ecs::world::World; + use bevy_ecs::{ + entity::Entity, + event::Events, + prelude::{Commands, Component, In, Query, With}, + query::Without, + schedule::{apply_deferred, IntoSystemConfigs, Schedule}, + system::RunSystemOnce, + world::World, + }; use bevy_hierarchy::{ despawn_with_children_recursive, BuildChildren, ChildBuild, Children, Parent, }; use bevy_math::{vec2, Rect, UVec2, Vec2}; - use bevy_render::camera::ManualTextureViews; - use bevy_render::camera::OrthographicProjection; - use bevy_render::prelude::Camera; - use bevy_render::texture::Image; - use bevy_transform::prelude::GlobalTransform; - use bevy_transform::systems::{propagate_transforms, sync_simple_transforms}; - use bevy_utils::prelude::default; - use bevy_utils::HashMap; - use bevy_window::PrimaryWindow; - use bevy_window::Window; - use bevy_window::WindowCreated; - use bevy_window::WindowResized; - use bevy_window::WindowResolution; - use bevy_window::WindowScaleFactorChanged; + use bevy_render::{ + camera::{ManualTextureViews, OrthographicProjection}, + prelude::Camera, + texture::Image, + }; + use bevy_transform::{ + prelude::GlobalTransform, + systems::{propagate_transforms, sync_simple_transforms}, + }; + use bevy_utils::{prelude::default, HashMap}; + use bevy_window::{ + PrimaryWindow, Window, WindowCreated, WindowResized, WindowResolution, + WindowScaleFactorChanged, + }; - use crate::layout::approx_round_layout_coords; - use crate::layout::ui_surface::UiSurface; - use crate::prelude::*; - use crate::ui_layout_system; - use crate::update::update_target_camera_system; - use crate::ContentSize; + use crate::{ + layout::{approx_round_layout_coords, ui_surface::UiSurface}, + prelude::*, + ui_layout_system, + update::update_target_camera_system, + ContentSize, + }; #[test] fn round_layout_coords_must_round_ties_up() { diff --git a/crates/bevy_ui/src/layout/ui_surface.rs b/crates/bevy_ui/src/layout/ui_surface.rs index 0cca1d6a0b..b5f0d29b9e 100644 --- a/crates/bevy_ui/src/layout/ui_surface.rs +++ b/crates/bevy_ui/src/layout/ui_surface.rs @@ -2,15 +2,17 @@ use std::fmt; use taffy::TaffyTree; -use bevy_ecs::entity::{Entity, EntityHashMap}; -use bevy_ecs::prelude::Resource; +use bevy_ecs::{ + entity::{Entity, EntityHashMap}, + prelude::Resource, +}; use bevy_hierarchy::Children; use bevy_math::UVec2; -use bevy_utils::default; -use bevy_utils::tracing::warn; +use bevy_utils::{default, tracing::warn}; -use crate::layout::convert; -use crate::{LayoutContext, LayoutError, Measure, MeasureArgs, NodeMeasure, Style}; +use crate::{ + layout::convert, LayoutContext, LayoutError, Measure, MeasureArgs, NodeMeasure, Style, +}; #[derive(Debug, Clone, PartialEq, Eq)] pub struct RootNodePair { diff --git a/crates/bevy_ui/src/lib.rs b/crates/bevy_ui/src/lib.rs index e1f46c405b..90089f58f4 100644 --- a/crates/bevy_ui/src/lib.rs +++ b/crates/bevy_ui/src/lib.rs @@ -21,8 +21,7 @@ pub mod widget; pub mod picking_backend; use bevy_derive::{Deref, DerefMut}; -use bevy_reflect::std_traits::ReflectDefault; -use bevy_reflect::Reflect; +use bevy_reflect::{std_traits::ReflectDefault, Reflect}; #[cfg(feature = "bevy_text")] mod accessibility; mod focus; diff --git a/crates/bevy_ui/src/measurement.rs b/crates/bevy_ui/src/measurement.rs index 647bc27a4a..9eca9de354 100644 --- a/crates/bevy_ui/src/measurement.rs +++ b/crates/bevy_ui/src/measurement.rs @@ -1,5 +1,4 @@ -use bevy_ecs::prelude::Component; -use bevy_ecs::reflect::ReflectComponent; +use bevy_ecs::{prelude::Component, reflect::ReflectComponent}; use bevy_math::Vec2; use bevy_reflect::{std_traits::ReflectDefault, Reflect}; use std::fmt::Formatter; diff --git a/crates/bevy_ui/src/render/mod.rs b/crates/bevy_ui/src/render/mod.rs index ead0059c2b..3160e65aed 100644 --- a/crates/bevy_ui/src/render/mod.rs +++ b/crates/bevy_ui/src/render/mod.rs @@ -4,15 +4,20 @@ mod ui_material_pipeline; pub mod ui_texture_slice_pipeline; use bevy_color::{Alpha, ColorToComponents, LinearRgba}; -use bevy_core_pipeline::core_2d::graph::{Core2d, Node2d}; -use bevy_core_pipeline::core_3d::graph::{Core3d, Node3d}; -use bevy_core_pipeline::{core_2d::Camera2d, core_3d::Camera3d}; +use bevy_core_pipeline::{ + core_2d::{ + graph::{Core2d, Node2d}, + Camera2d, + }, + core_3d::{ + graph::{Core3d, Node3d}, + Camera3d, + }, +}; use bevy_hierarchy::Parent; -use bevy_render::render_phase::ViewSortedRenderPhases; -use bevy_render::texture::TRANSPARENT_IMAGE_HANDLE; use bevy_render::{ - render_phase::{PhaseItem, PhaseItemExtraIndex}, - texture::GpuImage, + render_phase::{PhaseItem, PhaseItemExtraIndex, ViewSortedRenderPhases}, + texture::{GpuImage, TRANSPARENT_IMAGE_HANDLE}, view::ViewVisibility, ExtractSchedule, Render, }; @@ -22,16 +27,18 @@ pub use render_pass::*; pub use ui_material_pipeline::*; use ui_texture_slice_pipeline::UiTextureSlicerPlugin; -use crate::graph::{NodeUi, SubGraphUi}; use crate::{ + graph::{NodeUi, SubGraphUi}, BackgroundColor, BorderColor, CalculatedClip, DefaultUiCamera, Display, Node, Outline, Style, TargetCamera, UiAntiAlias, UiImage, UiScale, Val, }; use bevy_app::prelude::*; use bevy_asset::{load_internal_asset, AssetEvent, AssetId, Assets, Handle}; -use bevy_ecs::entity::{EntityHashMap, EntityHashSet}; -use bevy_ecs::prelude::*; +use bevy_ecs::{ + entity::{EntityHashMap, EntityHashSet}, + prelude::*, +}; use bevy_math::{FloatOrd, Mat4, Rect, URect, UVec4, Vec2, Vec3, Vec3Swizzles, Vec4, Vec4Swizzles}; use bevy_render::{ camera::Camera, diff --git a/crates/bevy_ui/src/render/ui_material_pipeline.rs b/crates/bevy_ui/src/render/ui_material_pipeline.rs index 1a3cf489ac..aa814cf081 100644 --- a/crates/bevy_ui/src/render/ui_material_pipeline.rs +++ b/crates/bevy_ui/src/render/ui_material_pipeline.rs @@ -5,8 +5,10 @@ use bevy_ecs::{ prelude::Component, query::ROQueryItem, storage::SparseSet, - system::lifetimeless::{Read, SRes}, - system::*, + system::{ + lifetimeless::{Read, SRes}, + *, + }, }; use bevy_hierarchy::Parent; use bevy_math::{FloatOrd, Mat4, Rect, Vec2, Vec4Swizzles}; diff --git a/crates/bevy_ui/src/ui_node.rs b/crates/bevy_ui/src/ui_node.rs index 9df4478eb6..b5489b4543 100644 --- a/crates/bevy_ui/src/ui_node.rs +++ b/crates/bevy_ui/src/ui_node.rs @@ -151,6 +151,7 @@ impl Default for Node { } /// The scroll position of the node. +/// /// Updating the values of `ScrollPosition` will reposition the children of the node by the offset amount. /// `ScrollPosition` may be updated by the layout system when a layout change makes a previously valid `ScrollPosition` invalid. /// Changing this does nothing on a `Node` without a `Style` setting at least one `OverflowAxis` to `OverflowAxis::Scroll`. @@ -2364,6 +2365,7 @@ mod tests { } /// Indicates that this root [`Node`] entity should be rendered to a specific camera. +/// /// UI then will be laid out respecting the camera's viewport and scale factor, and /// rendered to this camera's [`bevy_render::camera::RenderTarget`]. /// diff --git a/crates/bevy_ui/src/widget/button.rs b/crates/bevy_ui/src/widget/button.rs index dbe1405e92..19fe728b68 100644 --- a/crates/bevy_ui/src/widget/button.rs +++ b/crates/bevy_ui/src/widget/button.rs @@ -1,7 +1,5 @@ -use bevy_ecs::prelude::Component; -use bevy_ecs::reflect::ReflectComponent; -use bevy_reflect::std_traits::ReflectDefault; -use bevy_reflect::Reflect; +use bevy_ecs::{prelude::Component, reflect::ReflectComponent}; +use bevy_reflect::{std_traits::ReflectDefault, Reflect}; /// Marker struct for buttons #[derive(Component, Debug, Default, Clone, Copy, PartialEq, Eq, Reflect)] diff --git a/crates/bevy_ui/src/widget/label.rs b/crates/bevy_ui/src/widget/label.rs index 4aa7f7e36b..f464fea527 100644 --- a/crates/bevy_ui/src/widget/label.rs +++ b/crates/bevy_ui/src/widget/label.rs @@ -1,7 +1,5 @@ -use bevy_ecs::prelude::Component; -use bevy_ecs::reflect::ReflectComponent; -use bevy_reflect::std_traits::ReflectDefault; -use bevy_reflect::Reflect; +use bevy_ecs::{prelude::Component, reflect::ReflectComponent}; +use bevy_reflect::{std_traits::ReflectDefault, Reflect}; /// Marker struct for labels #[derive(Component, Debug, Default, Clone, Copy, Reflect)] diff --git a/crates/bevy_ui/src/widget/text.rs b/crates/bevy_ui/src/widget/text.rs index c7942a19d9..cb319a2881 100644 --- a/crates/bevy_ui/src/widget/text.rs +++ b/crates/bevy_ui/src/widget/text.rs @@ -144,6 +144,7 @@ fn create_text_measure( } /// Generates a new [`Measure`] for a text node on changes to its [`Text`] component. +/// /// A `Measure` is used by the UI's layout algorithm to determine the appropriate amount of space /// to provide for the text given the fonts, the text itself and the constraints of the layout. /// diff --git a/crates/bevy_utils/src/default.rs b/crates/bevy_utils/src/default.rs index 36f3e054ae..5b4b9fbdf9 100644 --- a/crates/bevy_utils/src/default.rs +++ b/crates/bevy_utils/src/default.rs @@ -1,4 +1,5 @@ /// An ergonomic abbreviation for [`Default::default()`] to make initializing structs easier. +/// /// This is especially helpful when combined with ["struct update syntax"](https://doc.rust-lang.org/book/ch05-01-defining-structs.html#creating-instances-from-other-instances-with-struct-update-syntax). /// ``` /// use bevy_utils::default; diff --git a/crates/bevy_utils/src/lib.rs b/crates/bevy_utils/src/lib.rs index 53442f7722..b8966e868b 100644 --- a/crates/bevy_utils/src/lib.rs +++ b/crates/bevy_utils/src/lib.rs @@ -12,7 +12,6 @@ //! General utilities for first-party [Bevy] engine crates. //! //! [Bevy]: https://bevyengine.org/ -//! #[cfg(feature = "alloc")] extern crate alloc; @@ -148,6 +147,7 @@ pub type HashSet = hashbrown::HashSet>; pub type StableHashSet = hashbrown::HashSet; /// A pre-hashed value of a specific type. Pre-hashing enables memoization of hashes that are expensive to compute. +/// /// It also enables faster [`PartialEq`] comparisons by short circuiting on hash equality. /// See [`PassHash`] and [`PassHasher`] for a "pass through" [`BuildHasher`] and [`Hasher`] implementation /// designed to work with [`Hashed`] diff --git a/crates/bevy_window/src/event.rs b/crates/bevy_window/src/event.rs index f7f0fd55c8..38591fcab3 100644 --- a/crates/bevy_window/src/event.rs +++ b/crates/bevy_window/src/event.rs @@ -155,7 +155,6 @@ pub struct CursorMoved { pub position: Vec2, /// The change in the position of the cursor since the last event was sent. /// This value is `None` if the cursor was outside the window area during the last frame. - // // Because the range of this data is limited by the display area and it may have been // transformed by the OS to implement effects such as cursor acceleration, it should // not be used to implement non-cursor-like interactions such as 3D camera control. diff --git a/crates/bevy_window/src/monitor.rs b/crates/bevy_window/src/monitor.rs index 756574596b..10cb3b226f 100644 --- a/crates/bevy_window/src/monitor.rs +++ b/crates/bevy_window/src/monitor.rs @@ -1,5 +1,4 @@ -use bevy_ecs::component::Component; -use bevy_ecs::prelude::ReflectComponent; +use bevy_ecs::{component::Component, prelude::ReflectComponent}; use bevy_math::{IVec2, UVec2}; use bevy_reflect::Reflect; diff --git a/crates/bevy_window/src/window.rs b/crates/bevy_window/src/window.rs index 6e80ed7474..a905107158 100644 --- a/crates/bevy_window/src/window.rs +++ b/crates/bevy_window/src/window.rs @@ -962,7 +962,6 @@ pub enum MonitorSelection { /// [`Mailbox`]: PresentMode::Mailbox /// [`AutoVsync`]: PresentMode::AutoVsync /// [`AutoNoVsync`]: PresentMode::AutoNoVsync -/// #[repr(C)] #[derive(Default, Copy, Clone, Debug, PartialEq, Eq, Hash, Reflect)] #[cfg_attr( diff --git a/crates/bevy_winit/src/accessibility.rs b/crates/bevy_winit/src/accessibility.rs index 05fc96c992..0ab68eb891 100644 --- a/crates/bevy_winit/src/accessibility.rs +++ b/crates/bevy_winit/src/accessibility.rs @@ -6,16 +6,18 @@ use std::{ }; use accesskit_winit::Adapter; -use bevy_a11y::accesskit::{ActivationHandler, DeactivationHandler, Node}; use bevy_a11y::{ - accesskit::{ActionHandler, ActionRequest, NodeBuilder, NodeId, Role, Tree, TreeUpdate}, - AccessibilityNode, AccessibilityRequested, AccessibilitySystem, Focus, + accesskit::{ + ActionHandler, ActionRequest, ActivationHandler, DeactivationHandler, Node, NodeBuilder, + NodeId, Role, Tree, TreeUpdate, + }, + AccessibilityNode, AccessibilityRequested, AccessibilitySystem, + ActionRequest as ActionRequestWrapper, Focus, ManageAccessibilityUpdates, }; -use bevy_a11y::{ActionRequest as ActionRequestWrapper, ManageAccessibilityUpdates}; use bevy_app::{App, Plugin, PostUpdate}; use bevy_derive::{Deref, DerefMut}; -use bevy_ecs::entity::EntityHashMap; use bevy_ecs::{ + entity::EntityHashMap, prelude::{DetectChanges, Entity, EventReader, EventWriter}, query::With, schedule::IntoSystemConfigs, diff --git a/crates/bevy_winit/src/lib.rs b/crates/bevy_winit/src/lib.rs index afad99ab09..7cb31a834f 100644 --- a/crates/bevy_winit/src/lib.rs +++ b/crates/bevy_winit/src/lib.rs @@ -27,16 +27,20 @@ pub use converters::convert_system_cursor_icon; pub use state::{CursorSource, CustomCursorCache, CustomCursorCacheKey, PendingCursor}; use system::{changed_windows, despawn_windows}; pub use system::{create_monitors, create_windows}; -pub use winit::event_loop::EventLoopProxy; #[cfg(all(target_family = "wasm", target_os = "unknown"))] pub use winit::platform::web::CustomCursorExtWebSys; -pub use winit::window::{CustomCursor as WinitCustomCursor, CustomCursorSource}; +pub use winit::{ + event_loop::EventLoopProxy, + window::{CustomCursor as WinitCustomCursor, CustomCursorSource}, +}; pub use winit_config::*; pub use winit_windows::*; -use crate::accessibility::{AccessKitAdapters, AccessKitPlugin, WinitActionRequestHandlers}; -use crate::state::winit_runner; -use crate::winit_monitors::WinitMonitors; +use crate::{ + accessibility::{AccessKitAdapters, AccessKitPlugin, WinitActionRequestHandlers}, + state::winit_runner, + winit_monitors::WinitMonitors, +}; pub mod accessibility; mod converters; diff --git a/crates/bevy_winit/src/state.rs b/crates/bevy_winit/src/state.rs index 4cff720878..1ca75d1fbb 100644 --- a/crates/bevy_winit/src/state.rs +++ b/crates/bevy_winit/src/state.rs @@ -1,11 +1,13 @@ use approx::relative_eq; use bevy_app::{App, AppExit, PluginsState}; -use bevy_ecs::change_detection::{DetectChanges, NonSendMut, Res}; -use bevy_ecs::entity::Entity; -use bevy_ecs::event::{EventCursor, EventWriter}; -use bevy_ecs::prelude::*; -use bevy_ecs::system::SystemState; -use bevy_ecs::world::FromWorld; +use bevy_ecs::{ + change_detection::{DetectChanges, NonSendMut, Res}, + entity::Entity, + event::{EventCursor, EventWriter}, + prelude::*, + system::SystemState, + world::FromWorld, +}; use bevy_input::{ gestures::*, keyboard::KeyboardFocusLost, @@ -17,12 +19,14 @@ use bevy_math::{ivec2, DVec2, Vec2}; use bevy_tasks::tick_global_task_pools_on_main_thread; use bevy_utils::{HashMap, Instant}; use std::marker::PhantomData; -use winit::application::ApplicationHandler; -use winit::dpi::PhysicalSize; -use winit::event; -use winit::event::{DeviceEvent, DeviceId, StartCause, WindowEvent}; -use winit::event_loop::{ActiveEventLoop, ControlFlow, EventLoop}; -use winit::window::WindowId; +use winit::{ + application::ApplicationHandler, + dpi::PhysicalSize, + event, + event::{DeviceEvent, DeviceId, StartCause, WindowEvent}, + event_loop::{ActiveEventLoop, ControlFlow, EventLoop}, + window::WindowId, +}; use bevy_window::{ AppLifecycle, CursorEntered, CursorLeft, CursorMoved, FileDragAndDrop, Ime, RequestRedraw, @@ -33,11 +37,12 @@ use bevy_window::{ #[cfg(target_os = "android")] use bevy_window::{PrimaryWindow, RawHandleWrapper}; -use crate::accessibility::AccessKitAdapters; -use crate::system::{create_monitors, CachedWindow}; use crate::{ - converters, create_windows, AppSendEvent, CreateMonitorParams, CreateWindowParams, - EventLoopProxyWrapper, UpdateMode, WinitSettings, WinitWindows, + accessibility::AccessKitAdapters, + converters, create_windows, + system::{create_monitors, CachedWindow}, + AppSendEvent, CreateMonitorParams, CreateWindowParams, EventLoopProxyWrapper, UpdateMode, + WinitSettings, WinitWindows, }; /// Persistent state that is used to run the [`App`] according to the current diff --git a/crates/bevy_winit/src/system.rs b/crates/bevy_winit/src/system.rs index bd9f2dee14..2fa86d1e51 100644 --- a/crates/bevy_winit/src/system.rs +++ b/crates/bevy_winit/src/system.rs @@ -12,27 +12,27 @@ use bevy_window::{ WindowClosing, WindowCreated, WindowMode, WindowResized, WindowWrapper, }; -use winit::dpi::{LogicalPosition, LogicalSize, PhysicalPosition, PhysicalSize}; -use winit::event_loop::ActiveEventLoop; +use winit::{ + dpi::{LogicalPosition, LogicalSize, PhysicalPosition, PhysicalSize}, + event_loop::ActiveEventLoop, +}; use bevy_app::AppExit; -use bevy_ecs::prelude::EventReader; -use bevy_ecs::query::With; -use bevy_ecs::system::Res; +use bevy_ecs::{prelude::EventReader, query::With, system::Res}; use bevy_math::{IVec2, UVec2}; #[cfg(target_os = "ios")] use winit::platform::ios::WindowExtIOS; #[cfg(target_arch = "wasm32")] use winit::platform::web::WindowExtWebSys; -use crate::state::react_to_resize; -use crate::winit_monitors::WinitMonitors; use crate::{ converters::{ convert_enabled_buttons, convert_window_level, convert_window_theme, convert_winit_theme, }, - get_best_videomode, get_fitting_videomode, select_monitor, CreateMonitorParams, - CreateWindowParams, WinitWindows, + get_best_videomode, get_fitting_videomode, select_monitor, + state::react_to_resize, + winit_monitors::WinitMonitors, + CreateMonitorParams, CreateWindowParams, WinitWindows, }; /// Creates new windows on the [`winit`] backend for each entity with a newly-added diff --git a/crates/bevy_winit/src/winit_config.rs b/crates/bevy_winit/src/winit_config.rs index e97831bb38..dc36e1d975 100644 --- a/crates/bevy_winit/src/winit_config.rs +++ b/crates/bevy_winit/src/winit_config.rs @@ -18,7 +18,7 @@ impl WinitSettings { pub fn game() -> Self { WinitSettings { focused_mode: UpdateMode::Continuous, - unfocused_mode: UpdateMode::reactive_low_power(Duration::from_secs_f64(1.0 / 60.0)), // 60Hz, + unfocused_mode: UpdateMode::reactive_low_power(Duration::from_secs_f64(1.0 / 60.0)), /* 60Hz, */ } } diff --git a/crates/bevy_winit/src/winit_monitors.rs b/crates/bevy_winit/src/winit_monitors.rs index 0b8c0073e8..e0b0f0fd32 100644 --- a/crates/bevy_winit/src/winit_monitors.rs +++ b/crates/bevy_winit/src/winit_monitors.rs @@ -1,7 +1,6 @@ use winit::monitor::MonitorHandle; -use bevy_ecs::entity::Entity; -use bevy_ecs::system::Resource; +use bevy_ecs::{entity::Entity, system::Resource}; /// Stores [`winit`] monitors and their corresponding entities /// diff --git a/crates/bevy_winit/src/winit_windows.rs b/crates/bevy_winit/src/winit_windows.rs index 90574e635d..299d0f92df 100644 --- a/crates/bevy_winit/src/winit_windows.rs +++ b/crates/bevy_winit/src/winit_windows.rs @@ -15,12 +15,12 @@ use winit::{ window::{CursorGrabMode as WinitCursorGrabMode, Fullscreen, Window as WinitWindow, WindowId}, }; -use crate::winit_monitors::WinitMonitors; use crate::{ accessibility::{ prepare_accessibility_for_window, AccessKitAdapters, WinitActionRequestHandlers, }, converters::{convert_enabled_buttons, convert_window_level, convert_window_theme}, + winit_monitors::WinitMonitors, }; /// A resource mapping window entities to their `winit`-backend [`Window`](winit::window::Window) @@ -393,7 +393,7 @@ pub fn winit_window_position( ) -> Option> { match position { WindowPosition::Automatic => { - /* Window manager will handle position */ + // Window manager will handle position None } WindowPosition::Centered(monitor_selection) => { diff --git a/examples/2d/custom_gltf_vertex_attribute.rs b/examples/2d/custom_gltf_vertex_attribute.rs index bf5ce108e9..c319e1b525 100644 --- a/examples/2d/custom_gltf_vertex_attribute.rs +++ b/examples/2d/custom_gltf_vertex_attribute.rs @@ -15,6 +15,7 @@ use bevy::{ const SHADER_ASSET_PATH: &str = "shaders/custom_gltf_2d.wgsl"; /// This vertex attribute supplies barycentric coordinates for each triangle. +/// /// Each component of the vector corresponds to one corner of a triangle. It's /// equal to 1.0 in that corner and 0.0 in the other two. Hence, its value in /// the fragment shader indicates proximity to a corner or the opposite edge. diff --git a/examples/2d/rotation.rs b/examples/2d/rotation.rs index 421fd3fbd3..43227ed502 100644 --- a/examples/2d/rotation.rs +++ b/examples/2d/rotation.rs @@ -1,7 +1,6 @@ //! Demonstrates rotating entities in 2D using quaternions. -use bevy::math::ops; -use bevy::prelude::*; +use bevy::{math::ops, prelude::*}; const BOUNDS: Vec2 = Vec2::new(1200.0, 640.0); diff --git a/examples/2d/sprite_animation.rs b/examples/2d/sprite_animation.rs index 88f51de2d3..74d3a2bf43 100644 --- a/examples/2d/sprite_animation.rs +++ b/examples/2d/sprite_animation.rs @@ -4,8 +4,7 @@ use std::time::Duration; -use bevy::input::common_conditions::input_just_pressed; -use bevy::prelude::*; +use bevy::{input::common_conditions::input_just_pressed, prelude::*}; fn main() { App::new() diff --git a/examples/3d/anti_aliasing.rs b/examples/3d/anti_aliasing.rs index 73530ef530..69bafcb30a 100644 --- a/examples/3d/anti_aliasing.rs +++ b/examples/3d/anti_aliasing.rs @@ -1,7 +1,6 @@ //! This example compares MSAA (Multi-Sample Anti-aliasing), FXAA (Fast Approximate Anti-aliasing), and TAA (Temporal Anti-aliasing). -use std::f32::consts::PI; -use std::fmt::Write; +use std::{f32::consts::PI, fmt::Write}; use bevy::{ core_pipeline::{ diff --git a/examples/3d/generate_custom_mesh.rs b/examples/3d/generate_custom_mesh.rs index 6a8b1315e2..4209c12152 100644 --- a/examples/3d/generate_custom_mesh.rs +++ b/examples/3d/generate_custom_mesh.rs @@ -2,11 +2,13 @@ //! assign a custom UV mapping for a custom texture, //! and how to change the UV mapping at run-time. -use bevy::prelude::*; -use bevy::render::{ - mesh::{Indices, VertexAttributeValues}, - render_asset::RenderAssetUsages, - render_resource::PrimitiveTopology, +use bevy::{ + prelude::*, + render::{ + mesh::{Indices, VertexAttributeValues}, + render_asset::RenderAssetUsages, + render_resource::PrimitiveTopology, + }, }; // Define a "marker" component to mark the custom mesh. Marker components are often used in Bevy for diff --git a/examples/3d/irradiance_volumes.rs b/examples/3d/irradiance_volumes.rs index e213c1f3a2..69e8dddfd0 100644 --- a/examples/3d/irradiance_volumes.rs +++ b/examples/3d/irradiance_volumes.rs @@ -13,14 +13,17 @@ //! //! * Clicking anywhere moves the object. -use bevy::color::palettes::css::*; -use bevy::core_pipeline::Skybox; -use bevy::math::{uvec3, vec3}; -use bevy::pbr::irradiance_volume::IrradianceVolume; -use bevy::pbr::{ExtendedMaterial, MaterialExtension, NotShadowCaster}; -use bevy::prelude::*; -use bevy::render::render_resource::{AsBindGroup, ShaderRef, ShaderType}; -use bevy::window::PrimaryWindow; +use bevy::{ + color::palettes::css::*, + core_pipeline::Skybox, + math::{uvec3, vec3}, + pbr::{ + irradiance_volume::IrradianceVolume, ExtendedMaterial, MaterialExtension, NotShadowCaster, + }, + prelude::*, + render::render_resource::{AsBindGroup, ShaderRef, ShaderType}, + window::PrimaryWindow, +}; /// This example uses a shader source file from the assets subdirectory const SHADER_ASSET_PATH: &str = "shaders/irradiance_volume_voxel_visualization.wgsl"; diff --git a/examples/3d/lightmaps.rs b/examples/3d/lightmaps.rs index 564a3162bb..a9e498492d 100644 --- a/examples/3d/lightmaps.rs +++ b/examples/3d/lightmaps.rs @@ -1,7 +1,6 @@ //! Rendering a scene with baked lightmaps. -use bevy::pbr::Lightmap; -use bevy::prelude::*; +use bevy::{pbr::Lightmap, prelude::*}; fn main() { App::new() diff --git a/examples/3d/pbr.rs b/examples/3d/pbr.rs index 5a25f99fca..ec5c0a4922 100644 --- a/examples/3d/pbr.rs +++ b/examples/3d/pbr.rs @@ -1,7 +1,6 @@ //! This example shows how to configure Physically Based Rendering (PBR) parameters. -use bevy::render::camera::ScalingMode; -use bevy::{asset::LoadState, prelude::*}; +use bevy::{asset::LoadState, prelude::*, render::camera::ScalingMode}; fn main() { App::new() diff --git a/examples/3d/reflection_probes.rs b/examples/3d/reflection_probes.rs index ca8f02441d..e126e8da35 100644 --- a/examples/3d/reflection_probes.rs +++ b/examples/3d/reflection_probes.rs @@ -6,8 +6,7 @@ //! //! Reflection probes don't work on WebGL 2 or WebGPU. -use bevy::core_pipeline::Skybox; -use bevy::prelude::*; +use bevy::{core_pipeline::Skybox, prelude::*}; use std::{ f32::consts::PI, diff --git a/examples/3d/scrolling_fog.rs b/examples/3d/scrolling_fog.rs index 50a029864e..837d4a5bca 100644 --- a/examples/3d/scrolling_fog.rs +++ b/examples/3d/scrolling_fog.rs @@ -10,12 +10,17 @@ //! The camera is looking at a pillar with the sun peaking behind it. The light //! interactions change based on the density of the fog. -use bevy::core_pipeline::bloom::Bloom; -use bevy::core_pipeline::experimental::taa::{TemporalAntiAliasBundle, TemporalAntiAliasPlugin}; -use bevy::pbr::{DirectionalLightShadowMap, FogVolume, VolumetricFog, VolumetricLight}; -use bevy::prelude::*; -use bevy::render::texture::{ - ImageAddressMode, ImageFilterMode, ImageLoaderSettings, ImageSampler, ImageSamplerDescriptor, +use bevy::{ + core_pipeline::{ + bloom::Bloom, + experimental::taa::{TemporalAntiAliasBundle, TemporalAntiAliasPlugin}, + }, + pbr::{DirectionalLightShadowMap, FogVolume, VolumetricFog, VolumetricLight}, + prelude::*, + render::texture::{ + ImageAddressMode, ImageFilterMode, ImageLoaderSettings, ImageSampler, + ImageSamplerDescriptor, + }, }; /// Initializes the example. diff --git a/examples/3d/transparency_3d.rs b/examples/3d/transparency_3d.rs index 3ea2be7457..5db6d7b693 100644 --- a/examples/3d/transparency_3d.rs +++ b/examples/3d/transparency_3d.rs @@ -2,8 +2,7 @@ //! Shows the effects of different blend modes. //! The `fade_transparency` system smoothly changes the transparency over time. -use bevy::math::ops; -use bevy::prelude::*; +use bevy::{math::ops, prelude::*}; fn main() { App::new() diff --git a/examples/animation/animated_fox.rs b/examples/animation/animated_fox.rs index a167e2b171..f10e2b66ee 100644 --- a/examples/animation/animated_fox.rs +++ b/examples/animation/animated_fox.rs @@ -1,7 +1,6 @@ //! Plays animations from a skinned glTF. -use std::f32::consts::PI; -use std::time::Duration; +use std::{f32::consts::PI, time::Duration}; use bevy::{ animation::{animate_targets, RepeatAnimation}, diff --git a/examples/animation/animated_transform.rs b/examples/animation/animated_transform.rs index 7fae355b9b..d5eb9780c9 100644 --- a/examples/animation/animated_transform.rs +++ b/examples/animation/animated_transform.rs @@ -2,8 +2,10 @@ use std::f32::consts::PI; -use bevy::animation::{AnimationTarget, AnimationTargetId}; -use bevy::prelude::*; +use bevy::{ + animation::{AnimationTarget, AnimationTargetId}, + prelude::*, +}; fn main() { App::new() diff --git a/examples/app/log_layers.rs b/examples/app/log_layers.rs index 31a40faf2f..fa7ddd1470 100644 --- a/examples/app/log_layers.rs +++ b/examples/app/log_layers.rs @@ -1,7 +1,10 @@ //! This example illustrates how to add custom log layers in bevy. -use bevy::log::BoxedLayer; -use bevy::{log::tracing_subscriber::Layer, prelude::*, utils::tracing::Subscriber}; +use bevy::{ + log::{tracing_subscriber::Layer, BoxedLayer}, + prelude::*, + utils::tracing::Subscriber, +}; struct CustomLayer; diff --git a/examples/app/log_layers_ecs.rs b/examples/app/log_layers_ecs.rs index 179a4715ad..1c8cb983c4 100644 --- a/examples/app/log_layers_ecs.rs +++ b/examples/app/log_layers_ecs.rs @@ -13,12 +13,13 @@ use std::sync::mpsc; -use bevy::log::BoxedLayer; use bevy::{ - log::tracing_subscriber::{self, Layer}, + log::{ + tracing_subscriber::{self, Layer}, + BoxedLayer, + }, prelude::*, - utils::tracing, - utils::tracing::Subscriber, + utils::{tracing, tracing::Subscriber}, }; /// A basic message. This is what we will be sending from the [`CaptureLayer`] to [`CapturedLogEvents`] non-send resource. diff --git a/examples/app/logs.rs b/examples/app/logs.rs index ffce34ffb4..b48bf4e977 100644 --- a/examples/app/logs.rs +++ b/examples/app/logs.rs @@ -1,7 +1,6 @@ //! This example illustrates how to use logs in bevy. -use bevy::log::once; -use bevy::prelude::*; +use bevy::{log::once, prelude::*}; fn main() { App::new() diff --git a/examples/app/without_winit.rs b/examples/app/without_winit.rs index 6a1b3782a3..e651efac73 100644 --- a/examples/app/without_winit.rs +++ b/examples/app/without_winit.rs @@ -1,7 +1,6 @@ //! Create an application without winit (runs single time, no event loop). -use bevy::prelude::*; -use bevy::winit::WinitPlugin; +use bevy::{prelude::*, winit::WinitPlugin}; fn main() { App::new() diff --git a/examples/asset/alter_mesh.rs b/examples/asset/alter_mesh.rs index 5bd3053af3..92e13efdf7 100644 --- a/examples/asset/alter_mesh.rs +++ b/examples/asset/alter_mesh.rs @@ -1,8 +1,10 @@ //! Shows how to modify mesh assets after spawning. use bevy::{ - gltf::GltfLoaderSettings, input::common_conditions::input_just_pressed, prelude::*, - render::mesh::VertexAttributeValues, render::render_asset::RenderAssetUsages, + gltf::GltfLoaderSettings, + input::common_conditions::input_just_pressed, + prelude::*, + render::{mesh::VertexAttributeValues, render_asset::RenderAssetUsages}, }; fn main() { diff --git a/examples/asset/asset_decompression.rs b/examples/asset/asset_decompression.rs index 4101d24bb2..70c0116d19 100644 --- a/examples/asset/asset_decompression.rs +++ b/examples/asset/asset_decompression.rs @@ -9,8 +9,7 @@ use bevy::{ reflect::TypePath, }; use flate2::read::GzDecoder; -use std::io::prelude::*; -use std::marker::PhantomData; +use std::{io::prelude::*, marker::PhantomData}; use thiserror::Error; #[derive(Asset, TypePath)] diff --git a/examples/asset/embedded_asset.rs b/examples/asset/embedded_asset.rs index 9066bfaba7..b60ec636b3 100644 --- a/examples/asset/embedded_asset.rs +++ b/examples/asset/embedded_asset.rs @@ -1,7 +1,9 @@ //! Example of loading an embedded asset. -use bevy::asset::{embedded_asset, io::AssetSourceId, AssetPath}; -use bevy::prelude::*; +use bevy::{ + asset::{embedded_asset, io::AssetSourceId, AssetPath}, + prelude::*, +}; use std::path::Path; fn main() { diff --git a/examples/asset/extra_source.rs b/examples/asset/extra_source.rs index 04d860d7af..4e0463e4b1 100644 --- a/examples/asset/extra_source.rs +++ b/examples/asset/extra_source.rs @@ -1,11 +1,13 @@ //! An example of registering an extra asset source, and loading assets from it. //! This asset source exists in addition to the default asset source. -use bevy::asset::{ - io::{AssetSourceBuilder, AssetSourceId}, - AssetPath, +use bevy::{ + asset::{ + io::{AssetSourceBuilder, AssetSourceId}, + AssetPath, + }, + prelude::*, }; -use bevy::prelude::*; use std::path::Path; fn main() { diff --git a/examples/async_tasks/async_compute.rs b/examples/async_tasks/async_compute.rs index d48223b339..2ac4149478 100644 --- a/examples/async_tasks/async_compute.rs +++ b/examples/async_tasks/async_compute.rs @@ -2,8 +2,7 @@ //! to spawn, poll, and complete tasks across systems and system ticks. use bevy::{ - ecs::system::SystemState, - ecs::world::CommandQueue, + ecs::{system::SystemState, world::CommandQueue}, prelude::*, tasks::{block_on, futures_lite::future, AsyncComputeTaskPool, Task}, }; diff --git a/examples/audio/audio_control.rs b/examples/audio/audio_control.rs index c8aef7ccf8..6adbded9e3 100644 --- a/examples/audio/audio_control.rs +++ b/examples/audio/audio_control.rs @@ -1,7 +1,6 @@ //! This example illustrates how to load and play an audio file, and control how it's played. -use bevy::math::ops; -use bevy::prelude::*; +use bevy::{math::ops, prelude::*}; fn main() { App::new() diff --git a/examples/audio/decodable.rs b/examples/audio/decodable.rs index 225868e96a..f364314ae1 100644 --- a/examples/audio/decodable.rs +++ b/examples/audio/decodable.rs @@ -1,11 +1,11 @@ //! Shows how to create a custom [`Decodable`] type by implementing a Sine wave. -use bevy::audio::AddAudioSource; -use bevy::audio::AudioPlugin; -use bevy::audio::Source; -use bevy::math::ops; -use bevy::prelude::*; -use bevy::reflect::TypePath; -use bevy::utils::Duration; +use bevy::{ + audio::{AddAudioSource, AudioPlugin, Source}, + math::ops, + prelude::*, + reflect::TypePath, + utils::Duration, +}; // This struct usually contains the data for the audio being played. // This is where data read from an audio file would be stored, for example. @@ -96,7 +96,7 @@ fn main() { fn setup(mut assets: ResMut>, mut commands: Commands) { // add a `SineAudio` to the asset server so that it can be played let audio_handle = assets.add(SineAudio { - frequency: 440., //this is the frequency of A4 + frequency: 440., // this is the frequency of A4 }); commands.spawn(AudioSourceBundle { source: audio_handle, diff --git a/examples/camera/2d_top_down_camera.rs b/examples/camera/2d_top_down_camera.rs index c94f004bf9..8f49e7bba6 100644 --- a/examples/camera/2d_top_down_camera.rs +++ b/examples/camera/2d_top_down_camera.rs @@ -9,10 +9,12 @@ //! | `A` | Move left | //! | `D` | Move right | -use bevy::core_pipeline::bloom::Bloom; -use bevy::math::vec3; -use bevy::prelude::*; -use bevy::sprite::{MaterialMesh2dBundle, Mesh2dHandle}; +use bevy::{ + core_pipeline::bloom::Bloom, + math::vec3, + prelude::*, + sprite::{MaterialMesh2dBundle, Mesh2dHandle}, +}; /// Player movement speed factor. const PLAYER_SPEED: f32 = 100.; diff --git a/examples/camera/first_person_view_model.rs b/examples/camera/first_person_view_model.rs index d3d30fc878..79bec51eed 100644 --- a/examples/camera/first_person_view_model.rs +++ b/examples/camera/first_person_view_model.rs @@ -44,11 +44,10 @@ use std::f32::consts::FRAC_PI_2; -use bevy::color::palettes::tailwind; -use bevy::input::mouse::AccumulatedMouseMotion; -use bevy::pbr::NotShadowCaster; -use bevy::prelude::*; -use bevy::render::view::RenderLayers; +use bevy::{ + color::palettes::tailwind, input::mouse::AccumulatedMouseMotion, pbr::NotShadowCaster, + prelude::*, render::view::RenderLayers, +}; fn main() { App::new() diff --git a/examples/ecs/component_hooks.rs b/examples/ecs/component_hooks.rs index 1828807da1..7598ad90ca 100644 --- a/examples/ecs/component_hooks.rs +++ b/examples/ecs/component_hooks.rs @@ -13,8 +13,10 @@ //! - Enforcing structural rules: When you have systems that depend on specific relationships //! between components (like hierarchies or parent-child links) and need to maintain correctness. -use bevy::ecs::component::{ComponentHooks, StorageType}; -use bevy::prelude::*; +use bevy::{ + ecs::component::{ComponentHooks, StorageType}, + prelude::*, +}; use std::collections::HashMap; #[derive(Debug)] diff --git a/examples/ecs/custom_query_param.rs b/examples/ecs/custom_query_param.rs index 43b02df732..6fb53092de 100644 --- a/examples/ecs/custom_query_param.rs +++ b/examples/ecs/custom_query_param.rs @@ -78,6 +78,7 @@ fn print_components_read_only( } /// If you are going to mutate the data in a query, you must mark it with the `mutable` attribute. +/// /// The [`QueryData`] derive macro will still create a read-only version, which will be have `ReadOnly` /// suffix. /// Note: if you want to use derive macros with read-only query variants, you need to pass them with diff --git a/examples/ecs/custom_schedule.rs b/examples/ecs/custom_schedule.rs index 564d00f401..aa6fe63658 100644 --- a/examples/ecs/custom_schedule.rs +++ b/examples/ecs/custom_schedule.rs @@ -1,9 +1,11 @@ //! Demonstrates how to add custom schedules that run in Bevy's `Main` schedule, ordered relative to Bevy's built-in //! schedules such as `Update` or `Last`. -use bevy::app::MainScheduleOrder; -use bevy::ecs::schedule::{ExecutorKind, ScheduleLabel}; -use bevy::prelude::*; +use bevy::{ + app::MainScheduleOrder, + ecs::schedule::{ExecutorKind, ScheduleLabel}, + prelude::*, +}; #[derive(ScheduleLabel, Debug, Hash, PartialEq, Eq, Clone)] struct SingleThreadedUpdate; diff --git a/examples/ecs/dynamic.rs b/examples/ecs/dynamic.rs index 855ed02c12..fe1523dd5b 100644 --- a/examples/ecs/dynamic.rs +++ b/examples/ecs/dynamic.rs @@ -5,13 +5,13 @@ use std::{alloc::Layout, io::Write, ptr::NonNull}; -use bevy::prelude::*; use bevy::{ ecs::{ component::{ComponentDescriptor, ComponentId, ComponentInfo, StorageType}, query::QueryData, world::FilteredEntityMut, }, + prelude::*, ptr::{Aligned, OwningPtr}, utils::HashMap, }; diff --git a/examples/ecs/hierarchy.rs b/examples/ecs/hierarchy.rs index 2729b63b3e..e3356d28e3 100644 --- a/examples/ecs/hierarchy.rs +++ b/examples/ecs/hierarchy.rs @@ -2,8 +2,7 @@ use std::f32::consts::*; -use bevy::color::palettes::css::*; -use bevy::prelude::*; +use bevy::{color::palettes::css::*, prelude::*}; fn main() { App::new() diff --git a/examples/ecs/parallel_query.rs b/examples/ecs/parallel_query.rs index 8eebb26da1..adf7f243da 100644 --- a/examples/ecs/parallel_query.rs +++ b/examples/ecs/parallel_query.rs @@ -1,7 +1,6 @@ //! Illustrates parallel queries with `ParallelIterator`. -use bevy::ecs::batching::BatchingStrategy; -use bevy::prelude::*; +use bevy::{ecs::batching::BatchingStrategy, prelude::*}; use rand::{Rng, SeedableRng}; use rand_chacha::ChaCha8Rng; diff --git a/examples/ecs/run_conditions.rs b/examples/ecs/run_conditions.rs index 39cc0a37f7..959753c93f 100644 --- a/examples/ecs/run_conditions.rs +++ b/examples/ecs/run_conditions.rs @@ -59,6 +59,7 @@ struct InputCounter(usize); struct Unused; /// Return true if any of the defined inputs were just pressed. +/// /// This is a custom run condition, it can take any normal system parameters as long as /// they are read only (except for local parameters which can be mutable). /// It returns a bool which determines if the system should run. @@ -75,6 +76,7 @@ fn has_user_input( } /// This is a function that returns a closure which can be used as a run condition. +/// /// This is useful because you can reuse the same run condition but with different variables. /// This is how the common conditions module works. fn time_passed(t: f32) -> impl FnMut(Local, Res