Skip to content

Commit

Permalink
make the examples use the States derive macro (#8289)
Browse files Browse the repository at this point in the history
# Objective
Some examples still manually implement the States trait, even though
manual implementation is no longer needed as there is now the derive
macro for that.

---------

Signed-off-by: Natalia Asteria <fortressnordlys@outlook.com>
  • Loading branch information
togetherwithasteria committed Apr 2, 2023
1 parent 9079f6d commit 7a9e77c
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 18 deletions.
10 changes: 1 addition & 9 deletions examples/2d/texture_atlas.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,21 +14,13 @@ fn main() {
.run();
}

#[derive(Debug, Clone, Copy, Default, PartialEq, Eq, Hash)]
#[derive(Debug, Clone, Copy, Default, PartialEq, Eq, Hash, States)]
enum AppState {
#[default]
Setup,
Finished,
}

impl States for AppState {
type Iter = std::array::IntoIter<AppState, 2>;

fn variants() -> Self::Iter {
[AppState::Setup, AppState::Finished].into_iter()
}
}

#[derive(Resource, Default)]
struct RpgSpriteHandles {
handles: Vec<HandleUntyped>,
Expand Down
10 changes: 1 addition & 9 deletions examples/ecs/generic_system.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,21 +11,13 @@

use bevy::prelude::*;

#[derive(Debug, Default, Clone, Copy, Eq, PartialEq, Hash)]
#[derive(Debug, Default, Clone, Copy, Eq, PartialEq, Hash, States)]
enum AppState {
#[default]
MainMenu,
InGame,
}

impl States for AppState {
type Iter = std::array::IntoIter<AppState, 2>;

fn variants() -> Self::Iter {
[AppState::MainMenu, AppState::InGame].into_iter()
}
}

#[derive(Component)]
struct TextToPrint(String);

Expand Down

0 comments on commit 7a9e77c

Please sign in to comment.