Remove unnecessary parentheses (#10990)

# Objective

- Increase readability.

## Solution

- Remove unnecessary parentheses.
This commit is contained in:
Tygyh 2023-12-16 03:26:18 +01:00 committed by GitHub
parent d3e96abadc
commit 696af48416
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 30 additions and 26 deletions

View File

@ -307,7 +307,7 @@ impl App {
} }
let runner = std::mem::replace(&mut app.runner, Box::new(run_once)); let runner = std::mem::replace(&mut app.runner, Box::new(run_once));
(runner)(app); runner(app);
} }
/// Check the state of all plugins already added to this app. This is usually called by the /// Check the state of all plugins already added to this app. This is usually called by the

View File

@ -319,7 +319,7 @@ impl<A: Asset> Assets<A> {
) -> &mut A { ) -> &mut A {
let id: AssetId<A> = id.into(); let id: AssetId<A> = id.into();
if self.get(id).is_none() { if self.get(id).is_none() {
self.insert(id, (insert_fn)()); self.insert(id, insert_fn());
} }
self.get_mut(id).unwrap() self.get_mut(id).unwrap()
} }

View File

@ -555,7 +555,7 @@ mod tests {
fn run_app_until(app: &mut App, mut predicate: impl FnMut(&mut World) -> Option<()>) { fn run_app_until(app: &mut App, mut predicate: impl FnMut(&mut World) -> Option<()>) {
for _ in 0..LARGE_ITERATION_COUNT { for _ in 0..LARGE_ITERATION_COUNT {
app.update(); app.update();
if (predicate)(&mut app.world).is_some() { if predicate(&mut app.world).is_some() {
return; return;
} }
} }

View File

@ -653,8 +653,12 @@ pub struct EventIteratorWithId<'a, E: Event> {
impl<'a, E: Event> EventIteratorWithId<'a, E> { impl<'a, E: Event> EventIteratorWithId<'a, E> {
/// Creates a new iterator that yields any `events` that have not yet been seen by `reader`. /// Creates a new iterator that yields any `events` that have not yet been seen by `reader`.
pub fn new(reader: &'a mut ManualEventReader<E>, events: &'a Events<E>) -> Self { pub fn new(reader: &'a mut ManualEventReader<E>, events: &'a Events<E>) -> Self {
let a_index = (reader.last_event_count).saturating_sub(events.events_a.start_event_count); let a_index = reader
let b_index = (reader.last_event_count).saturating_sub(events.events_b.start_event_count); .last_event_count
.saturating_sub(events.events_a.start_event_count);
let b_index = reader
.last_event_count
.saturating_sub(events.events_b.start_event_count);
let a = events.events_a.get(a_index..).unwrap_or_default(); let a = events.events_a.get(a_index..).unwrap_or_default();
let b = events.events_b.get(b_index..).unwrap_or_default(); let b = events.events_b.get(b_index..).unwrap_or_default();

View File

@ -1675,7 +1675,7 @@ impl ScheduleGraph {
let a_systems = set_system_bitsets.get(a).unwrap(); let a_systems = set_system_bitsets.get(a).unwrap();
let b_systems = set_system_bitsets.get(b).unwrap(); let b_systems = set_system_bitsets.get(b).unwrap();
if !(a_systems.is_disjoint(b_systems)) { if !a_systems.is_disjoint(b_systems) {
return Err(ScheduleBuildError::SetsHaveOrderButIntersect( return Err(ScheduleBuildError::SetsHaveOrderButIntersect(
self.get_node_name(a), self.get_node_name(a),
self.get_node_name(b), self.get_node_name(b),

View File

@ -313,7 +313,7 @@ impl BlobVec {
let drop = self.drop; let drop = self.drop;
let value = self.swap_remove_and_forget_unchecked(index); let value = self.swap_remove_and_forget_unchecked(index);
if let Some(drop) = drop { if let Some(drop) = drop {
(drop)(value); drop(value);
} }
} }

View File

@ -540,7 +540,7 @@ pub fn extract_default_ui_camera_view<T: Component>(
ui_scale: Extract<Res<UiScale>>, ui_scale: Extract<Res<UiScale>>,
query: Extract<Query<(Entity, &Camera, Option<&UiCameraConfig>), With<T>>>, query: Extract<Query<(Entity, &Camera, Option<&UiCameraConfig>), With<T>>>,
) { ) {
let scale = (ui_scale.0).recip(); let scale = ui_scale.0.recip();
for (entity, camera, camera_ui) in &query { for (entity, camera, camera_ui) in &query {
// ignore cameras with disabled ui // ignore cameras with disabled ui
if matches!(camera_ui, Some(&UiCameraConfig { show_ui: false, .. })) { if matches!(camera_ui, Some(&UiCameraConfig { show_ui: false, .. })) {

View File

@ -216,24 +216,24 @@ mod tests {
.map(|entity| query.get(&world, *entity).unwrap().clone()) .map(|entity| query.get(&world, *entity).unwrap().clone())
.collect::<Vec<_>>(); .collect::<Vec<_>>();
let expected_result = vec![ let expected_result = vec![
(Label("1-2-1")), // ZIndex::Global(-3) Label("1-2-1"), // ZIndex::Global(-3)
(Label("3")), // ZIndex::Global(-2) Label("3"), // ZIndex::Global(-2)
(Label("1-2")), // ZIndex::Global(-1) Label("1-2"), // ZIndex::Global(-1)
(Label("1-2-0")), Label("1-2-0"),
(Label("1-2-2")), Label("1-2-2"),
(Label("1-2-3")), Label("1-2-3"),
(Label("2")), Label("2"),
(Label("2-0")), Label("2-0"),
(Label("2-1")), Label("2-1"),
(Label("2-1-0")), Label("2-1-0"),
(Label("1")), // ZIndex::Local(1) Label("1"), // ZIndex::Local(1)
(Label("1-0")), Label("1-0"),
(Label("1-0-2")), // ZIndex::Local(-1) Label("1-0-2"), // ZIndex::Local(-1)
(Label("1-0-0")), Label("1-0-0"),
(Label("1-0-1")), Label("1-0-1"),
(Label("1-1")), Label("1-1"),
(Label("1-3")), Label("1-3"),
(Label("0")), // ZIndex::Global(2) Label("0"), // ZIndex::Global(2)
]; ];
assert_eq!(actual_result, expected_result); assert_eq!(actual_result, expected_result);
} }