Skip to content

Commit b17f8a4

Browse files
committed
format comments (#1612)
Uses the new unstable comment formatting features added to rustfmt.toml.
1 parent be1c317 commit b17f8a4

File tree

125 files changed

+894
-599
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

125 files changed

+894
-599
lines changed

crates/bevy_app/src/app.rs

+9-8
Original file line numberDiff line numberDiff line change
@@ -9,24 +9,25 @@ use bevy_utils::tracing::info_span;
99
#[allow(clippy::needless_doctest_main)]
1010
/// Containers of app logic and data
1111
///
12-
/// App store the ECS World, Resources, Schedule, and Executor. They also store the "run" function of the App, which
13-
/// by default executes the App schedule once. Apps are constructed using the builder pattern.
12+
/// App store the ECS World, Resources, Schedule, and Executor. They also store the "run" function
13+
/// of the App, which by default executes the App schedule once. Apps are constructed using the
14+
/// builder pattern.
1415
///
1516
/// ## Example
1617
/// Here is a simple "Hello World" Bevy app:
1718
/// ```
18-
///# use bevy_app::prelude::*;
19-
///# use bevy_ecs::prelude::*;
19+
/// # use bevy_app::prelude::*;
20+
/// # use bevy_ecs::prelude::*;
2021
///
21-
///fn main() {
22+
/// fn main() {
2223
/// App::build()
2324
/// .add_system(hello_world_system.system())
2425
/// .run();
25-
///}
26+
/// }
2627
///
27-
///fn hello_world_system() {
28+
/// fn hello_world_system() {
2829
/// println!("hello world");
29-
///}
30+
/// }
3031
/// ```
3132
pub struct App {
3233
pub world: World,

crates/bevy_app/src/app_builder.rs

+5-4
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,8 @@ impl AppBuilder {
234234
.add_system_to_stage(CoreStage::First, Events::<T>::update_system.system())
235235
}
236236

237-
/// Inserts a resource to the current [App] and overwrites any resource previously added of the same type.
237+
/// Inserts a resource to the current [App] and overwrites any resource previously added of the
238+
/// same type.
238239
pub fn insert_resource<T>(&mut self, resource: T) -> &mut Self
239240
where
240241
T: Component,
@@ -255,9 +256,9 @@ impl AppBuilder {
255256
where
256257
R: FromWorld + Send + Sync + 'static,
257258
{
258-
// PERF: We could avoid double hashing here, since the `from_resources` call is guaranteed not to
259-
// modify the map. However, we would need to be borrowing resources both mutably and immutably,
260-
// so we would need to be extremely certain this is correct
259+
// PERF: We could avoid double hashing here, since the `from_resources` call is guaranteed
260+
// not to modify the map. However, we would need to be borrowing resources both
261+
// mutably and immutably, so we would need to be extremely certain this is correct
261262
if !self.world_mut().contains_resource::<R>() {
262263
let resource = R::from_world(self.world_mut());
263264
self.insert_resource(resource);

crates/bevy_app/src/event.rs

+30-19
Original file line numberDiff line numberDiff line change
@@ -55,10 +55,12 @@ enum State {
5555
B,
5656
}
5757

58-
/// An event collection that represents the events that occurred within the last two [Events::update] calls. Events can be cheaply read using
59-
/// an [EventReader]. This collection is meant to be paired with a system that calls [Events::update] exactly once per update/frame. [Events::update_system]
60-
/// is a system that does this. [EventReader]s are expected to read events from this collection at least once per update/frame. If events are not handled
61-
/// within one frame/update, they will be dropped.
58+
/// An event collection that represents the events that occurred within the last two
59+
/// [Events::update] calls. Events can be cheaply read using an [EventReader]. This collection is
60+
/// meant to be paired with a system that calls [Events::update] exactly once per update/frame.
61+
/// [Events::update_system] is a system that does this. [EventReader]s are expected to read events
62+
/// from this collection at least once per update/frame. If events are not handled within one
63+
/// frame/update, they will be dropped.
6264
///
6365
/// # Example
6466
/// ```
@@ -89,14 +91,16 @@ enum State {
8991
///
9092
/// # Details
9193
///
92-
/// [Events] is implemented using a double buffer. Each call to [Events::update] swaps buffers and clears out the oldest buffer.
93-
/// [EventReader]s that read at least once per update will never drop events. [EventReader]s that read once within two updates might
94-
/// still receive some events. [EventReader]s that read after two updates are guaranteed to drop all events that occurred before those updates.
94+
/// [Events] is implemented using a double buffer. Each call to [Events::update] swaps buffers and
95+
/// clears out the oldest buffer. [EventReader]s that read at least once per update will never drop
96+
/// events. [EventReader]s that read once within two updates might still receive some events.
97+
/// [EventReader]s that read after two updates are guaranteed to drop all events that occurred
98+
/// before those updates.
9599
///
96100
/// The buffers in [Events] will grow indefinitely if [Events::update] is never called.
97101
///
98-
/// An alternative call pattern would be to call [Events::update] manually across frames to control when events are cleared. However
99-
/// this complicates consumption
102+
/// An alternative call pattern would be to call [Events::update] manually across frames to control
103+
/// when events are cleared. However this complicates consumption
100104
#[derive(Debug)]
101105
pub struct Events<T> {
102106
events_a: Vec<EventInstance<T>>,
@@ -180,7 +184,8 @@ impl<T> ManualEventReader<T> {
180184
}
181185
}
182186

183-
/// Like [`iter_with_id`](EventReader::iter_with_id) except not emitting any traces for read messages.
187+
/// Like [`iter_with_id`](EventReader::iter_with_id) except not emitting any traces for read
188+
/// messages.
184189
fn internal_event_reader<'a, T>(
185190
last_event_count: &mut usize,
186191
events: &'a Events<T>,
@@ -232,7 +237,8 @@ fn internal_event_reader<'a, T>(
232237

233238
impl<'a, T: Component> EventReader<'a, T> {
234239
/// Iterates over the events this EventReader has not seen yet. This updates the EventReader's
235-
/// event counter, which means subsequent event reads will not include events that happened before now.
240+
/// event counter, which means subsequent event reads will not include events that happened
241+
/// before now.
236242
pub fn iter(&mut self) -> impl DoubleEndedIterator<Item = &T> {
237243
self.iter_with_id().map(|(event, _id)| event)
238244
}
@@ -247,7 +253,8 @@ impl<'a, T: Component> EventReader<'a, T> {
247253
}
248254

249255
impl<T: Component> Events<T> {
250-
/// "Sends" an `event` by writing it to the current event buffer. [EventReader]s can then read the event.
256+
/// "Sends" an `event` by writing it to the current event buffer. [EventReader]s can then read
257+
/// the event.
251258
pub fn send(&mut self, event: T) {
252259
let event_id = EventId {
253260
id: self.event_count,
@@ -273,15 +280,17 @@ impl<T: Component> Events<T> {
273280
}
274281
}
275282

276-
/// Gets a new [ManualEventReader]. This will ignore all events already in the event buffers. It will read all future events.
283+
/// Gets a new [ManualEventReader]. This will ignore all events already in the event buffers. It
284+
/// will read all future events.
277285
pub fn get_reader_current(&self) -> ManualEventReader<T> {
278286
ManualEventReader {
279287
last_event_count: self.event_count,
280288
_marker: PhantomData,
281289
}
282290
}
283291

284-
/// Swaps the event buffers and clears the oldest event buffer. In general, this should be called once per frame/update.
292+
/// Swaps the event buffers and clears the oldest event buffer. In general, this should be
293+
/// called once per frame/update.
285294
pub fn update(&mut self) {
286295
match self.state {
287296
State::A => {
@@ -335,10 +344,11 @@ impl<T: Component> Events<T> {
335344
}
336345

337346
/// Iterates over events that happened since the last "update" call.
338-
/// WARNING: You probably don't want to use this call. In most cases you should use an `EventReader`. You should only use
339-
/// this if you know you only need to consume events between the last `update()` call and your call to `iter_current_update_events`.
340-
/// If events happen outside that window, they will not be handled. For example, any events that happen after this call and before
341-
/// the next `update()` call will be dropped.
347+
/// WARNING: You probably don't want to use this call. In most cases you should use an
348+
/// `EventReader`. You should only use this if you know you only need to consume events
349+
/// between the last `update()` call and your call to `iter_current_update_events`.
350+
/// If events happen outside that window, they will not be handled. For example, any events that
351+
/// happen after this call and before the next `update()` call will be dropped.
342352
pub fn iter_current_update_events(&self) -> impl DoubleEndedIterator<Item = &T> {
343353
match self.state {
344354
State::A => self.events_a.iter().map(map_instance_event),
@@ -363,7 +373,8 @@ mod tests {
363373
let event_1 = TestEvent { i: 1 };
364374
let event_2 = TestEvent { i: 2 };
365375

366-
// this reader will miss event_0 and event_1 because it wont read them over the course of two updates
376+
// this reader will miss event_0 and event_1 because it wont read them over the course of
377+
// two updates
367378
let mut reader_missed = events.get_reader();
368379

369380
let mut reader_a = events.get_reader();

crates/bevy_app/src/lib.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,8 @@ pub enum CoreStage {
3333
First,
3434
/// Name of app stage responsible for performing setup before an update. Runs before UPDATE.
3535
PreUpdate,
36-
/// Name of app stage responsible for doing most app logic. Systems should be registered here by default.
36+
/// Name of app stage responsible for doing most app logic. Systems should be registered here
37+
/// by default.
3738
Update,
3839
/// Name of app stage responsible for processing the results of UPDATE. Runs after UPDATE.
3940
PostUpdate,

crates/bevy_app/src/plugin.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@ use std::any::Any;
33

44
/// A collection of Bevy App logic and configuration
55
///
6-
/// Plugins use [AppBuilder] to configure an [App](crate::App). When an [App](crate::App) registers a plugin, the plugin's [Plugin::build] function is run.
6+
/// Plugins use [AppBuilder] to configure an [App](crate::App). When an [App](crate::App) registers
7+
/// a plugin, the plugin's [Plugin::build] function is run.
78
pub trait Plugin: Any + Send + Sync {
89
fn build(&self, app: &mut AppBuilder);
910
fn name(&self) -> &str {

crates/bevy_app/src/schedule_runner.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,8 @@ impl ScheduleRunnerSettings {
4141
}
4242
}
4343

44-
/// Configures an App to run its [Schedule](bevy_ecs::schedule::Schedule) according to a given [RunMode]
44+
/// Configures an App to run its [Schedule](bevy_ecs::schedule::Schedule) according to a given
45+
/// [RunMode]
4546
#[derive(Default)]
4647
pub struct ScheduleRunnerPlugin {}
4748

crates/bevy_asset/src/asset_server.rs

+4-2
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,8 @@ impl AssetServer {
226226
let asset_loader = self.get_path_asset_loader(asset_path.path())?;
227227
let asset_path_id: AssetPathId = asset_path.get_id();
228228

229-
// load metadata and update source info. this is done in a scope to ensure we release the locks before loading
229+
// load metadata and update source info. this is done in a scope to ensure we release the
230+
// locks before loading
230231
let version = {
231232
let mut asset_sources = self.server.asset_sources.write();
232233
let source_info = match asset_sources.entry(asset_path_id.source_path_id()) {
@@ -282,7 +283,8 @@ impl AssetServer {
282283
.await
283284
.map_err(AssetServerError::AssetLoaderError)?;
284285

285-
// if version has changed since we loaded and grabbed a lock, return. theres is a newer version being loaded
286+
// if version has changed since we loaded and grabbed a lock, return. theres is a newer
287+
// version being loaded
286288
let mut asset_sources = self.server.asset_sources.write();
287289
let source_info = asset_sources
288290
.get_mut(&asset_path_id.source_path_id())

crates/bevy_asset/src/filesystem_watcher.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@ use crossbeam_channel::Receiver;
22
use notify::{Event, RecommendedWatcher, RecursiveMode, Result, Watcher};
33
use std::path::Path;
44

5-
/// Watches for changes to assets on the filesystem. This is used by the `AssetServer` to reload them
5+
/// Watches for changes to assets on the filesystem. This is used by the `AssetServer` to reload
6+
/// them
67
pub struct FilesystemWatcher {
78
pub watcher: RecommendedWatcher,
89
pub receiver: Receiver<Result<Event>>,

crates/bevy_asset/src/handle.rs

+8-4
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,8 @@ impl HandleId {
5656

5757
/// A handle into a specific Asset of type `T`
5858
///
59-
/// Handles contain a unique id that corresponds to a specific asset in the [Assets](crate::Assets) collection.
59+
/// Handles contain a unique id that corresponds to a specific asset in the [Assets](crate::Assets)
60+
/// collection.
6061
#[derive(Reflect)]
6162
#[reflect(Component)]
6263
pub struct Handle<T>
@@ -147,7 +148,8 @@ impl<T: Asset> Drop for Handle<T> {
147148
fn drop(&mut self) {
148149
match self.handle_type {
149150
HandleType::Strong(ref sender) => {
150-
// ignore send errors because this means the channel is shut down / the game has stopped
151+
// ignore send errors because this means the channel is shut down / the game has
152+
// stopped
151153
let _ = sender.send(RefChange::Decrement(self.id));
152154
}
153155
HandleType::Weak => {}
@@ -233,7 +235,8 @@ unsafe impl<T: Asset> Sync for Handle<T> {}
233235

234236
/// A non-generic version of [Handle]
235237
///
236-
/// This allows handles to be mingled in a cross asset context. For example, storing `Handle<A>` and `Handle<B>` in the same `HashSet<HandleUntyped>`.
238+
/// This allows handles to be mingled in a cross asset context. For example, storing `Handle<A>` and
239+
/// `Handle<B>` in the same `HashSet<HandleUntyped>`.
237240
#[derive(Debug)]
238241
pub struct HandleUntyped {
239242
pub id: HandleId,
@@ -299,7 +302,8 @@ impl Drop for HandleUntyped {
299302
fn drop(&mut self) {
300303
match self.handle_type {
301304
HandleType::Strong(ref sender) => {
302-
// ignore send errors because this means the channel is shut down / the game has stopped
305+
// ignore send errors because this means the channel is shut down / the game has
306+
// stopped
303307
let _ = sender.send(RefChange::Decrement(self.id));
304308
}
305309
HandleType::Weak => {}

crates/bevy_asset/src/lib.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,8 @@ pub enum AssetStage {
3939
AssetEvents,
4040
}
4141

42-
/// Adds support for Assets to an App. Assets are typed collections with change tracking, which are added as App Resources.
43-
/// Examples of assets: textures, sounds, 3d models, maps, scenes
42+
/// Adds support for Assets to an App. Assets are typed collections with change tracking, which are
43+
/// added as App Resources. Examples of assets: textures, sounds, 3d models, maps, scenes
4444
#[derive(Default)]
4545
pub struct AssetPlugin;
4646

crates/bevy_core/src/bytes.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -101,8 +101,8 @@ unsafe impl Byteable for isize {}
101101
unsafe impl Byteable for f32 {}
102102
unsafe impl Byteable for f64 {}
103103
unsafe impl Byteable for Vec2 {}
104-
// NOTE: Vec3 actually takes up the size of 4 floats / 16 bytes due to SIMD. This is actually convenient because GLSL
105-
// uniform buffer objects pad Vec3s to be 16 bytes.
104+
// NOTE: Vec3 actually takes up the size of 4 floats / 16 bytes due to SIMD. This is actually
105+
// convenient because GLSL uniform buffer objects pad Vec3s to be 16 bytes.
106106
unsafe impl Byteable for Vec3 {}
107107
unsafe impl Byteable for Vec4 {}
108108

crates/bevy_core/src/float_ord.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@ use std::{
55
ops::Neg,
66
};
77

8-
/// A wrapper type that enables ordering floats. This is a work around for the famous "rust float ordering" problem.
9-
/// By using it, you acknowledge that sorting NaN is undefined according to spec. This implementation treats NaN as the
10-
/// "smallest" float.
8+
/// A wrapper type that enables ordering floats. This is a work around for the famous "rust float
9+
/// ordering" problem. By using it, you acknowledge that sorting NaN is undefined according to spec.
10+
/// This implementation treats NaN as the "smallest" float.
1111
#[derive(Debug, Copy, Clone, PartialOrd)]
1212
pub struct FloatOrd(pub f32);
1313

crates/bevy_core/src/label.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,8 @@ impl Labels {
6161
}
6262
}
6363

64-
/// Maintains a mapping from [Entity](bevy_ecs::prelude::Entity) ids to entity labels and entity labels to [Entities](bevy_ecs::prelude::Entity).
64+
/// Maintains a mapping from [Entity](bevy_ecs::prelude::Entity) ids to entity labels and entity
65+
/// labels to [Entities](bevy_ecs::prelude::Entity).
6566
#[derive(Debug, Default)]
6667
pub struct EntityLabels {
6768
label_entities: HashMap<Cow<'static, str>, Vec<Entity>>,

crates/bevy_core/src/lib.rs

+4-2
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,8 @@ pub struct CorePlugin;
3131

3232
#[derive(Debug, PartialEq, Eq, Clone, Hash, SystemLabel)]
3333
pub enum CoreSystem {
34-
/// Updates the elapsed time. Any system that interacts with [Time] component should run after this.
34+
/// Updates the elapsed time. Any system that interacts with [Time] component should run after
35+
/// this.
3536
Time,
3637
}
3738

@@ -54,7 +55,8 @@ impl Plugin for CorePlugin {
5455
.register_type::<Labels>()
5556
.register_type::<Range<f32>>()
5657
.register_type::<Timer>()
57-
// time system is added as an "exclusive system" to ensure it runs before other systems in CoreStage::First
58+
// time system is added as an "exclusive system" to ensure it runs before other systems
59+
// in CoreStage::First
5860
.add_system_to_stage(
5961
CoreStage::First,
6062
time_system.exclusive_system().label(CoreSystem::Time),

crates/bevy_core/src/task_pool_options.rs

+4-2
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,11 @@ impl TaskPoolThreadAssignmentPolicy {
3636
/// this helper will do nothing.
3737
#[derive(Clone)]
3838
pub struct DefaultTaskPoolOptions {
39-
/// If the number of physical cores is less than min_total_threads, force using min_total_threads
39+
/// If the number of physical cores is less than min_total_threads, force using
40+
/// min_total_threads
4041
pub min_total_threads: usize,
41-
/// If the number of physical cores is grater than max_total_threads, force using max_total_threads
42+
/// If the number of physical cores is grater than max_total_threads, force using
43+
/// max_total_threads
4244
pub max_total_threads: usize,
4345

4446
/// Used to determine number of IO threads to allocate

crates/bevy_core/src/time/fixed_timestep.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -169,8 +169,8 @@ impl System for FixedTimestep {
169169
}
170170

171171
unsafe fn run_unsafe(&mut self, _input: Self::In, world: &World) -> Self::Out {
172-
// SAFE: this system inherits the internal system's component access and archetype component access,
173-
// which means the caller has ensured running the internal system is safe
172+
// SAFE: this system inherits the internal system's component access and archetype component
173+
// access, which means the caller has ensured running the internal system is safe
174174
self.internal_system.run_unsafe((), world)
175175
}
176176

crates/bevy_core/src/time/timer.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@ use bevy_utils::Duration;
66
/// Tracks elapsed time. Enters the finished state once `duration` is reached.
77
///
88
/// Non repeating timers will stop tracking and stay in the finished state until reset.
9-
/// Repeating timers will only be in the finished state on each tick `duration` is reached or exceeded, and can still be reset at any given point.
9+
/// Repeating timers will only be in the finished state on each tick `duration` is reached or
10+
/// exceeded, and can still be reset at any given point.
1011
///
1112
/// Paused timers will not have elapsed time increased.
1213
#[derive(Clone, Debug, Default, Reflect)]

crates/bevy_derive/src/lib.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ mod shader_defs;
1111

1212
use proc_macro::TokenStream;
1313

14-
/// Derives the FromResources trait. Each field must also implement the FromResources trait or this will fail. FromResources is
15-
/// automatically implemented for types that implement Default.
14+
/// Derives the FromResources trait. Each field must also implement the FromResources trait or this
15+
/// will fail. FromResources is automatically implemented for types that implement Default.
1616
#[proc_macro_derive(FromResources, attributes(as_crate))]
1717
pub fn derive_from_resources(input: TokenStream) -> TokenStream {
1818
resource::derive_from_resources(input)

0 commit comments

Comments
 (0)