Skip to content

Commit

Permalink
Compiler panicked
Browse files Browse the repository at this point in the history
rustc 1.58.0-nightly (dd549dcab 2021-11-25) running on x86_64-pc-windows-msvc
  • Loading branch information
gentoid committed Dec 6, 2021
1 parent 80f48e7 commit 720373d
Showing 1 changed file with 19 additions and 9 deletions.
28 changes: 19 additions & 9 deletions src/ui/toggle_switch.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
use bevy::{ecs::query::QueryEntityError, prelude::*};
use bevy::{
ecs::query::{FilterFetch, QueryEntityError, QueryItem, WorldQuery},
prelude::*,
};

pub struct ToggleSwitchPlugin;

Expand Down Expand Up @@ -151,16 +154,11 @@ fn toggle(
let is_enabled = !toggle_state.0;
toggle_state.0 = is_enabled;

let rr = children
.first()
.ok_or(QueryEntityError::NoSuchEntity)
.and_then(|child| slider_keepers_query.get_mut(*child))
let rr = first_child(slider_keepers_query)(children)
.map(update_slider_keeper(is_enabled))
.and_then(|children| children.first().ok_or(QueryEntityError::NoSuchEntity))
.and_then(|child| sliders_query.get_mut(*child))
.and_then(first_child(sliders_query))
.map(update_slider_border(&is_enabled, &materials))
.and_then(|children| children.first().ok_or(QueryEntityError::NoSuchEntity))
.and_then(|child| slider_body_query.get_mut(*child))
.and_then(first_child(slider_body_query))
.map(update_clider_body(&is_enabled, &materials));

if let Err(err) = rr {
Expand All @@ -171,6 +169,18 @@ fn toggle(
}
}

fn first_child<'w, 's, Q: WorldQuery, F: WorldQuery>(
query: Query<'w, 's, Q, F>,
) -> impl FnOnce(&Children) -> Result<QueryItem<Q>, QueryEntityError>
where
F::Fetch: FilterFetch,
{
move |children| children
.first()
.ok_or(QueryEntityError::NoSuchEntity)
.and_then(|child| query.get_mut(*child))
}

fn does_cursor_hover_element(
size: Size<Val>,
global_transform: &GlobalTransform,
Expand Down

0 comments on commit 720373d

Please sign in to comment.