Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ManualEventIterator does not implement Debug #9284

Closed
Zoomulator opened this issue Jul 26, 2023 · 0 comments · Fixed by #9293
Closed

ManualEventIterator does not implement Debug #9284

Zoomulator opened this issue Jul 26, 2023 · 0 comments · Fixed by #9293
Labels
A-ECS Entities, components, systems, and events C-Usability A targeted quality-of-life change that makes Bevy easier to use D-Trivial Nice and easy! A great choice to get started with Bevy

Comments

@Zoomulator
Copy link
Contributor

Zoomulator commented Jul 26, 2023

Bevy version

0.11

What you did

I wanted to reduce some incoming events into a single value. I expect left click events to only happen once (at least for now, I know it's probably not ideal) for the system and if it doesn't it'll just log the error via the try operator (?).

fn my_system(mut mouse_button_events: EventReader<MouseButtonInput>) -> Result<(), Box<dyn Error>>{
  if let Some(interaction) = mouse_button_events
      .iter()
      .flat_map(|event| match (event.button, event.state) {
          (MouseButton::Left, ButtonState::Pressed) => Some(Interaction::Pressed),
          (MouseButton::Left, ButtonState::Released) => Some(Interaction::Hovered),
          _ => None,
      })
      .at_most_one()?;
      // ...
}

What went wrong

The compiler complained that ManualEventIterator does not implement Debug, which is required to generate the at_most_one error result.

Additional information

You can work around this by adding .collect_vec().into_iter() between the flat_map and at_most_one calls.

@Zoomulator Zoomulator added C-Bug An unexpected or incorrect behavior S-Needs-Triage This issue needs to be labelled labels Jul 26, 2023
@alice-i-cecile alice-i-cecile added D-Trivial Nice and easy! A great choice to get started with Bevy A-ECS Entities, components, systems, and events C-Usability A targeted quality-of-life change that makes Bevy easier to use and removed C-Bug An unexpected or incorrect behavior S-Needs-Triage This issue needs to be labelled labels Jul 27, 2023
github-merge-queue bot pushed a commit that referenced this issue Jul 30, 2023
# Objective
Fixes #9284 by deriving Debug on ManualEventIterator
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-ECS Entities, components, systems, and events C-Usability A targeted quality-of-life change that makes Bevy easier to use D-Trivial Nice and easy! A great choice to get started with Bevy
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants