diff --git a/amethyst_core/src/frame_limiter.rs b/amethyst_core/src/frame_limiter.rs index 02c6d24167..c809c6c518 100644 --- a/amethyst_core/src/frame_limiter.rs +++ b/amethyst_core/src/frame_limiter.rs @@ -25,7 +25,7 @@ //! use amethyst::core::frame_limiter::FrameRateLimitStrategy; //! //! # struct GameState; -//! # impl<'a, 'b> SimpleState<'a, 'b> for GameState {} +//! # impl SimpleState for GameState {} //! # fn main() -> amethyst::Result<()> { //! let mut game = Application::build("./", GameState)? //! .with_frame_limit( diff --git a/book/src/concepts/state.md b/book/src/concepts/state.md index 9634ce81bc..141d879a54 100644 --- a/book/src/concepts/state.md +++ b/book/src/concepts/state.md @@ -102,7 +102,7 @@ struct GameplayState { player_count: u8, } -impl<'a,'b> SimpleState<'a,'b> for GameplayState { +impl SimpleState for GameplayState { fn on_start(&mut self, _data: StateData) { println!("Number of players: {}", self.player_count); } @@ -116,7 +116,7 @@ We first declare the `State`'s struct `GameplayState`. In this case, we give it some data: `player_count`, a byte. Then, we implement the `SimpleState` trait for our `GameplayState`. -`SimpleState` is a shorthand for `State, ()>` where `GameData` is the internal shared data between states. +`SimpleState` is a shorthand for `State, ()>` where `GameData` is the internal shared data between states. ### Switching State diff --git a/book/src/concepts/system.md b/book/src/concepts/system.md index 60e64b2e23..b1e522df17 100644 --- a/book/src/concepts/system.md +++ b/book/src/concepts/system.md @@ -357,8 +357,8 @@ impl Default for Game { struct GameplayState; -impl<'a, 'b> SimpleState<'a, 'b> for GameplayState { - fn update(&mut self, data: &mut StateData) -> SimpleTrans<'a, 'b> { +impl SimpleState for GameplayState { + fn update(&mut self, data: &mut StateData) -> SimpleTrans { // If the `Game` resource has been set up to go back to the menu, pop // the state so that we go back. @@ -379,8 +379,8 @@ impl<'a, 'b> SimpleState<'a, 'b> for GameplayState { struct GameMenuState; -impl<'a, 'b> SimpleState<'a, 'b> for GameMenuState { - fn update(&mut self, data: &mut StateData) -> SimpleTrans<'a, 'b> { +impl SimpleState for GameMenuState { + fn update(&mut self, data: &mut StateData) -> SimpleTrans { let mut game = data.world.write_resource::(); match game.user_action.take() { diff --git a/book/src/pong-tutorial/pong-tutorial-01.md b/book/src/pong-tutorial/pong-tutorial-01.md index a9068b5fa0..67afe91d95 100644 --- a/book/src/pong-tutorial/pong-tutorial-01.md +++ b/book/src/pong-tutorial/pong-tutorial-01.md @@ -44,7 +44,7 @@ just implement two methods: # use amethyst::renderer::{DisplayConfig, DrawFlat, Pipeline, # PosTex, RenderBundle, Stage}; # struct Pong; -impl<'a, 'b> SimpleState<'a, 'b> for Pong { +impl SimpleState for Pong { } ``` @@ -166,7 +166,7 @@ Now let's pack everything up and run it: # let path = "./resources/display_config.ron"; # let config = DisplayConfig::load(&path); # struct Pong; -# impl<'a, 'b> SimpleState<'a,'b> for Pong { } +# impl SimpleState for Pong { } let pipe = Pipeline::build() .with_stage( # Stage::with_backbuffer() diff --git a/book/src/pong-tutorial/pong-tutorial-02.md b/book/src/pong-tutorial/pong-tutorial-02.md index 0ce5fc97ea..a4a1149005 100644 --- a/book/src/pong-tutorial/pong-tutorial-02.md +++ b/book/src/pong-tutorial/pong-tutorial-02.md @@ -56,7 +56,7 @@ We will leave it empty for now, but it will become useful later down the line. # extern crate amethyst; # use amethyst::prelude::*; # struct MyState; -# impl<'a, 'b> SimpleState<'a, 'b> for MyState { +# impl SimpleState for MyState { fn on_start(&mut self, data: StateData) { } @@ -141,7 +141,7 @@ our State's `on_start` method: # use amethyst::ecs::World; # fn initialise_camera(world: &mut World) { } # struct MyState; -# impl<'a, 'b> SimpleState<'a, 'b> for MyState { +# impl SimpleState for MyState { fn on_start(&mut self, data: StateData) { let world = data.world; @@ -289,7 +289,7 @@ compiles. Update the `on_start` method to the following: # fn initialise_paddles(world: &mut World) { } # fn initialise_camera(world: &mut World) { } # struct MyState; -# impl<'a, 'b> SimpleState<'a, 'b> for MyState { +# impl SimpleState for MyState { fn on_start(&mut self, data: StateData) { let world = data.world; @@ -383,7 +383,7 @@ fn main() -> amethyst::Result<()> { # .with_pass(DrawFlat2D::new()), # ); # struct Pong; -# impl<'a, 'b> SimpleState<'a, 'b> for Pong { } +# impl SimpleState for Pong { } let game_data = GameDataBuilder::default() .with_bundle( RenderBundle::new(pipe, Some(config)) @@ -602,7 +602,7 @@ all together in the `on_start()` method: # fn initialise_camera(world: &mut World) { } # fn load_sprite_sheet(world: &mut World) -> SpriteSheetHandle { unimplemented!() } # struct MyState; -# impl<'a, 'b> SimpleState<'a, 'b> for MyState { +# impl SimpleState for MyState { fn on_start(&mut self, data: StateData) { let world = data.world; diff --git a/book/src/pong-tutorial/pong-tutorial-03.md b/book/src/pong-tutorial/pong-tutorial-03.md index cb9625ac5c..96b9d2cc2c 100644 --- a/book/src/pong-tutorial/pong-tutorial-03.md +++ b/book/src/pong-tutorial/pong-tutorial-03.md @@ -76,7 +76,7 @@ let input_bundle = InputBundle::::new() # .with_pass(DrawFlat::::new()), # ); # struct Pong; -# impl<'a, 'b> SimpleState<'a, 'b> for Pong { } +# impl SimpleState for Pong { } let game_data = GameDataBuilder::default() .with_bundle(RenderBundle::new(pipe, Some(config)).with_sprite_sheet_processor())? .with_bundle(TransformBundle::new())? @@ -370,7 +370,7 @@ will take care of that for us, as well as set up the storage. # fn initialise_camera(world: &mut World) { } # fn load_sprite_sheet(world: &mut World) -> SpriteSheetHandle { unimplemented!() } # struct MyState; -# impl<'a, 'b> SimpleState<'a, 'b> for MyState { +# impl SimpleState for MyState { fn on_start(&mut self, data: StateData) { let world = data.world; diff --git a/book/src/pong-tutorial/pong-tutorial-04.md b/book/src/pong-tutorial/pong-tutorial-04.md index 73d96efdda..e2c9b7d342 100644 --- a/book/src/pong-tutorial/pong-tutorial-04.md +++ b/book/src/pong-tutorial/pong-tutorial-04.md @@ -113,7 +113,7 @@ Finally, let's make sure the code is working as intended by updating the `on_sta # fn initialise_camera(world: &mut World) { } # fn load_sprite_sheet(world: &mut World) -> SpriteSheetHandle { unimplemented!() } # struct MyState; -# impl<'a, 'b> SimpleState<'a, 'b> for MyState { +# impl SimpleState for MyState { fn on_start(&mut self, data: StateData) { let world = data.world; diff --git a/book/src/pong-tutorial/pong-tutorial-05.md b/book/src/pong-tutorial/pong-tutorial-05.md index 18c8cbf3a9..e1367e04f8 100644 --- a/book/src/pong-tutorial/pong-tutorial-05.md +++ b/book/src/pong-tutorial/pong-tutorial-05.md @@ -286,7 +286,7 @@ use amethyst::{ # # pub struct Pong; # -# impl<'a, 'b> SimpleState<'a, 'b> for Pong { +# impl SimpleState for Pong { # fn on_start(&mut self, data: StateData) { # let world = data.world; # @@ -487,7 +487,7 @@ use amethyst::{ # # pub struct Pong; # -impl<'a, 'b> SimpleState<'a, 'b> for Pong { +impl SimpleState for Pong { fn on_start(&mut self, data: StateData) { # let world = data.world; # diff --git a/book/src/sprites/display_the_texture.md b/book/src/sprites/display_the_texture.md index 0d04c9745f..dce82b3aa6 100644 --- a/book/src/sprites/display_the_texture.md +++ b/book/src/sprites/display_the_texture.md @@ -44,7 +44,7 @@ fn init_image(world: &mut World, texture_handle: &TextureHandle) { #[derive(Debug)] struct ExampleState; -impl<'a, 'b> SimpleState<'a, 'b> for ExampleState { +impl SimpleState for ExampleState { fn on_start(&mut self, data: StateData) { let world = data.world; let texture_handle = load_texture("texture/sprite_sheet.png", world); diff --git a/book/src/sprites/load_the_texture.md b/book/src/sprites/load_the_texture.md index 3b2885a973..044501ef1e 100644 --- a/book/src/sprites/load_the_texture.md +++ b/book/src/sprites/load_the_texture.md @@ -27,7 +27,7 @@ where #[derive(Debug)] struct ExampleState; -impl<'a, 'b> SimpleState<'a, 'b> for ExampleState { +impl SimpleState for ExampleState { fn on_start(&mut self, data: StateData) { let texture_handle = load_texture("texture/sprite_sheet.png", &data.world); } diff --git a/book/src/sprites/orthographic_camera.md b/book/src/sprites/orthographic_camera.md index 6ac63355fd..0c79ea5629 100644 --- a/book/src/sprites/orthographic_camera.md +++ b/book/src/sprites/orthographic_camera.md @@ -16,7 +16,7 @@ use amethyst::renderer::{ #[derive(Debug)] struct ExampleState; -impl<'a, 'b> SimpleState<'a, 'b> for ExampleState { +impl SimpleState for ExampleState { fn on_start(&mut self, mut data: StateData) { // ... diff --git a/book/src/sprites/set_up_the_render_pass.md b/book/src/sprites/set_up_the_render_pass.md index 20677bd679..51194b6454 100644 --- a/book/src/sprites/set_up_the_render_pass.md +++ b/book/src/sprites/set_up_the_render_pass.md @@ -20,7 +20,7 @@ use amethyst::renderer::{ # #[derive(Debug, Default)] # struct ExampleState; # -# impl<'a, 'b> SimpleState<'a, 'b> for ExampleState {} +# impl SimpleState for ExampleState {} fn main() -> amethyst::Result<()> { # amethyst::start_logger(Default::default()); diff --git a/book/src/sprites/sprite_render_component.md b/book/src/sprites/sprite_render_component.md index b4ed886c33..83b9493c5f 100644 --- a/book/src/sprites/sprite_render_component.md +++ b/book/src/sprites/sprite_render_component.md @@ -37,7 +37,7 @@ use amethyst::renderer::{ #[derive(Debug)] struct ExampleState; -impl<'a, 'b> SimpleState<'a, 'b> for ExampleState { +impl SimpleState for ExampleState { fn on_start(&mut self, mut data: StateData) { # let texture_handle = load_texture("texture/sprite_sheet.png", &data.world); // ... @@ -82,7 +82,7 @@ use amethyst::renderer::{ #[derive(Debug)] struct ExampleState; -impl<'a, 'b> SimpleState<'a, 'b> for ExampleState { +impl SimpleState for ExampleState { fn on_start(&mut self, mut data: StateData) { # let texture_handle = load_texture("texture/sprite_sheet.png", &data.world); # diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index 1c5ab11915..08dab0a66c 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -43,6 +43,7 @@ The format is based on [Keep a Changelog][kc], and this project adheres to * Renamed the `DrawSprite` pass to `DrawFlat2D` as it now handles both sprites and images without spritesheets. ([#1153]) * `BasicScenePrefab` deserialization now returns an error on invalid fields. ([#1164]) * Reordered arguments for `Transform::set_rotation_euler` to match nalgebra's Euler angles. ([#1052]) +* Remove lifetimes from `SimpleState` ([#1198]) ### Removed @@ -85,6 +86,7 @@ The format is based on [Keep a Changelog][kc], and this project adheres to [#1184]: https://github.com/amethyst/amethyst/pull/1184 [#1187]: https://github.com/amethyst/amethyst/pull/1187 [#1188]: https://github.com/amethyst/amethyst/pull/1188 +[#1198]: https://github.com/amethyst/amethyst/pull/1198 [winit_018]: https://github.com/tomaka/winit/blob/v0.18.0/CHANGELOG.md#version-0180-2018-11-07 [glutin_019]: https://github.com/tomaka/glutin/blob/master/CHANGELOG.md#version-0190-2018-11-09 @@ -703,3 +705,4 @@ The format is based on [Keep a Changelog][kc], and this project adheres to [0.4.1]: https://github.com/amethyst/amethyst/compare/v0.4...v0.4.1 [0.4.0]: https://github.com/amethyst/amethyst/compare/v0.3.1...v0.4 [0.3.1]: https://github.com/amethyst/amethyst/compare/v0.3...v0.3.1 + diff --git a/examples/animation/main.rs b/examples/animation/main.rs index b4ee9e9c80..210341341e 100644 --- a/examples/animation/main.rs +++ b/examples/animation/main.rs @@ -46,7 +46,7 @@ impl Default for Example { } } -impl<'a, 'b> SimpleState<'a, 'b> for Example { +impl SimpleState for Example { fn on_start(&mut self, data: StateData) { let StateData { world, .. } = data; // Initialise the scene with an object, a light and a camera. @@ -56,11 +56,7 @@ impl<'a, 'b> SimpleState<'a, 'b> for Example { self.sphere = Some(world.create_entity().with(prefab_handle).build()); } - fn handle_event( - &mut self, - data: StateData, - event: StateEvent, - ) -> SimpleTrans<'a, 'b> { + fn handle_event(&mut self, data: StateData, event: StateEvent) -> SimpleTrans { let StateData { world, .. } = data; if let StateEvent::Window(event) = &event { if is_close_requested(&event) || is_key_down(&event, VirtualKeyCode::Escape) { diff --git a/examples/appendix_a/pong.rs b/examples/appendix_a/pong.rs index c371f40a53..22c1abc6bd 100644 --- a/examples/appendix_a/pong.rs +++ b/examples/appendix_a/pong.rs @@ -19,7 +19,7 @@ use crate::{ pub struct Pong; -impl<'a, 'b> SimpleState<'a, 'b> for Pong { +impl SimpleState for Pong { fn on_start(&mut self, data: StateData) { let StateData { world, .. } = data; use crate::audio::initialise_audio; diff --git a/examples/arc_ball_camera/main.rs b/examples/arc_ball_camera/main.rs index 9a6a50fbd4..8dc5f5b1ef 100644 --- a/examples/arc_ball_camera/main.rs +++ b/examples/arc_ball_camera/main.rs @@ -22,7 +22,7 @@ type MyPrefabData = BasicScenePrefab>; struct ExampleState; -impl<'a, 'b> SimpleState<'a, 'b> for ExampleState { +impl SimpleState for ExampleState { fn on_start(&mut self, data: StateData) { let prefab_handle = data.world.exec(|loader: PrefabLoader| { loader.load("prefab/arc_ball_camera.ron", RonFormat, (), ()) diff --git a/examples/asset_loading/main.rs b/examples/asset_loading/main.rs index 67f60e5d7d..7f394ef92b 100644 --- a/examples/asset_loading/main.rs +++ b/examples/asset_loading/main.rs @@ -63,7 +63,7 @@ impl SimpleFormat for Custom { struct AssetsExample; -impl<'a, 'b> SimpleState<'a, 'b> for AssetsExample { +impl SimpleState for AssetsExample { fn on_start(&mut self, data: StateData) { let StateData { world, .. } = data; world.add_resource(0usize); diff --git a/examples/custom_ui/main.rs b/examples/custom_ui/main.rs index b43a7cfc91..900bafda5e 100644 --- a/examples/custom_ui/main.rs +++ b/examples/custom_ui/main.rs @@ -75,7 +75,7 @@ impl ToNativeWidget for CustomUi { struct Example; -impl<'a, 'b> SimpleState<'a, 'b> for Example { +impl SimpleState for Example { fn on_start(&mut self, data: StateData) { let StateData { world, .. } = data; // Initialise the scene with an object, a light and a camera. diff --git a/examples/debug_lines/main.rs b/examples/debug_lines/main.rs index af479d26dc..05184a2cf2 100644 --- a/examples/debug_lines/main.rs +++ b/examples/debug_lines/main.rs @@ -44,7 +44,7 @@ impl<'s> System<'s> for ExampleLinesSystem { } struct ExampleState; -impl<'a, 'b> SimpleState<'a, 'b> for ExampleState { +impl SimpleState for ExampleState { fn on_start(&mut self, data: StateData) { // Setup debug lines as a resource data.world diff --git a/examples/fly_camera/main.rs b/examples/fly_camera/main.rs index 34059dd644..296a3b9eeb 100644 --- a/examples/fly_camera/main.rs +++ b/examples/fly_camera/main.rs @@ -17,7 +17,7 @@ type MyPrefabData = BasicScenePrefab>; struct ExampleState; -impl<'a, 'b> SimpleState<'a, 'b> for ExampleState { +impl SimpleState for ExampleState { fn on_start(&mut self, data: StateData) { let prefab_handle = data.world.exec(|loader: PrefabLoader| { loader.load("prefab/fly_camera.ron", RonFormat, (), ()) diff --git a/examples/gltf/main.rs b/examples/gltf/main.rs index f4afae8172..36b72feb86 100644 --- a/examples/gltf/main.rs +++ b/examples/gltf/main.rs @@ -51,7 +51,7 @@ struct ScenePrefabData { fly_tag: Option, } -impl<'a, 'b> SimpleState<'a, 'b> for Example { +impl SimpleState for Example { fn on_start(&mut self, data: StateData) { let StateData { world, .. } = data; @@ -69,11 +69,7 @@ impl<'a, 'b> SimpleState<'a, 'b> for Example { ); } - fn handle_event( - &mut self, - data: StateData, - event: StateEvent, - ) -> SimpleTrans<'a, 'b> { + fn handle_event(&mut self, data: StateData, event: StateEvent) -> SimpleTrans { let StateData { world, .. } = data; if let StateEvent::Window(event) = &event { if is_close_requested(&event) || is_key_down(&event, VirtualKeyCode::Escape) { @@ -94,7 +90,7 @@ impl<'a, 'b> SimpleState<'a, 'b> for Example { } } - fn update(&mut self, data: &mut StateData) -> SimpleTrans<'a, 'b> { + fn update(&mut self, data: &mut StateData) -> SimpleTrans { if !self.initialised { let remove = match self.progress.as_ref().map(|p| p.complete()) { None | Some(Completion::Loading) => false, diff --git a/examples/locale/main.rs b/examples/locale/main.rs index 6138e1eeba..601720fcd2 100644 --- a/examples/locale/main.rs +++ b/examples/locale/main.rs @@ -27,7 +27,7 @@ impl Example { } } -impl<'a, 'b> SimpleState<'a, 'b> for Example { +impl SimpleState for Example { fn on_start(&mut self, data: StateData) { data.world.add_resource(AssetStorage::::new()); let mut progress_counter = ProgressCounter::default(); @@ -56,7 +56,7 @@ impl<'a, 'b> SimpleState<'a, 'b> for Example { self.progress_counter = Some(progress_counter); } - fn update(&mut self, data: &mut StateData) -> SimpleTrans<'a, 'b> { + fn update(&mut self, data: &mut StateData) -> SimpleTrans { // Check if the locale has been loaded. if self.progress_counter.as_ref().unwrap().is_complete() { let store = data.world.read_resource::>(); diff --git a/examples/material/main.rs b/examples/material/main.rs index b917556545..3dc3bfe366 100644 --- a/examples/material/main.rs +++ b/examples/material/main.rs @@ -13,7 +13,7 @@ use amethyst::{ struct Example; -impl<'a, 'b> SimpleState<'a, 'b> for Example { +impl SimpleState for Example { fn on_start(&mut self, data: StateData) { let StateData { world, .. } = data; let mat_defaults = world.read_resource::().0.clone(); diff --git a/examples/net_client/main.rs b/examples/net_client/main.rs index a9c69d711a..4bd9674865 100644 --- a/examples/net_client/main.rs +++ b/examples/net_client/main.rs @@ -31,7 +31,7 @@ fn main() -> Result<()> { /// Default empty state pub struct State1; -impl<'a, 'b> SimpleState<'a, 'b> for State1 { +impl SimpleState for State1 { fn on_start(&mut self, data: StateData) { data.world .create_entity() diff --git a/examples/net_server/main.rs b/examples/net_server/main.rs index 2211c2fc56..ed730859aa 100644 --- a/examples/net_server/main.rs +++ b/examples/net_server/main.rs @@ -30,7 +30,7 @@ fn main() -> Result<()> { /// Default empty state pub struct State1; -impl<'a, 'b> SimpleState<'a, 'b> for State1 { +impl SimpleState for State1 { fn on_start(&mut self, data: StateData) { data.world .create_entity() diff --git a/examples/pong/pong.rs b/examples/pong/pong.rs index dd95964a47..fc94c9678e 100644 --- a/examples/pong/pong.rs +++ b/examples/pong/pong.rs @@ -13,7 +13,7 @@ use crate::{systems::ScoreText, Ball, Paddle, Side, ARENA_HEIGHT, ARENA_WIDTH}; pub struct Pong; -impl<'a, 'b> SimpleState<'a, 'b> for Pong { +impl SimpleState for Pong { fn on_start(&mut self, data: StateData) { let StateData { world, .. } = data; use crate::audio::initialise_audio; diff --git a/examples/pong_tutorial_01/main.rs b/examples/pong_tutorial_01/main.rs index aead71bebf..c7f761e074 100644 --- a/examples/pong_tutorial_01/main.rs +++ b/examples/pong_tutorial_01/main.rs @@ -8,7 +8,7 @@ use amethyst::{ pub struct Pong; -impl<'a, 'b> SimpleState<'a, 'b> for Pong {} +impl SimpleState for Pong {} fn main() -> amethyst::Result<()> { amethyst::start_logger(Default::default()); diff --git a/examples/pong_tutorial_02/pong.rs b/examples/pong_tutorial_02/pong.rs index 31d6f7d8d5..25b8cda478 100644 --- a/examples/pong_tutorial_02/pong.rs +++ b/examples/pong_tutorial_02/pong.rs @@ -17,7 +17,7 @@ const PADDLE_WIDTH: f32 = 4.0; pub struct Pong; -impl<'a, 'b> SimpleState<'a, 'b> for Pong { +impl SimpleState for Pong { fn on_start(&mut self, data: StateData) { let world = data.world; diff --git a/examples/pong_tutorial_03/pong.rs b/examples/pong_tutorial_03/pong.rs index 04eddf4883..678bc5e176 100644 --- a/examples/pong_tutorial_03/pong.rs +++ b/examples/pong_tutorial_03/pong.rs @@ -17,7 +17,7 @@ pub const PADDLE_WIDTH: f32 = 4.0; pub struct Pong; -impl<'a, 'b> SimpleState<'a, 'b> for Pong { +impl SimpleState for Pong { fn on_start(&mut self, data: StateData) { let world = data.world; diff --git a/examples/pong_tutorial_04/pong.rs b/examples/pong_tutorial_04/pong.rs index e88df17991..24c53b8daa 100644 --- a/examples/pong_tutorial_04/pong.rs +++ b/examples/pong_tutorial_04/pong.rs @@ -21,7 +21,7 @@ pub const BALL_RADIUS: f32 = 2.0; pub struct Pong; -impl<'a, 'b> SimpleState<'a, 'b> for Pong { +impl SimpleState for Pong { fn on_start(&mut self, data: StateData) { let world = data.world; diff --git a/examples/pong_tutorial_05/pong.rs b/examples/pong_tutorial_05/pong.rs index 84bb3db807..36b1fb3fc5 100644 --- a/examples/pong_tutorial_05/pong.rs +++ b/examples/pong_tutorial_05/pong.rs @@ -22,7 +22,7 @@ pub const BALL_RADIUS: f32 = 2.0; pub struct Pong; -impl<'a, 'b> SimpleState<'a, 'b> for Pong { +impl SimpleState for Pong { fn on_start(&mut self, data: StateData) { let world = data.world; diff --git a/examples/prefab/main.rs b/examples/prefab/main.rs index cf804fb4e3..0d2491a1a9 100644 --- a/examples/prefab/main.rs +++ b/examples/prefab/main.rs @@ -16,7 +16,7 @@ type MyPrefabData = BasicScenePrefab>; struct AssetsExample; -impl<'a, 'b> SimpleState<'a, 'b> for AssetsExample { +impl SimpleState for AssetsExample { fn on_start(&mut self, data: StateData) { let prefab_handle = data.world.exec(|loader: PrefabLoader| { loader.load("prefab/example.ron", RonFormat, (), ()) diff --git a/examples/renderable/main.rs b/examples/renderable/main.rs index 1a617e01c4..8550bd5aa1 100644 --- a/examples/renderable/main.rs +++ b/examples/renderable/main.rs @@ -40,7 +40,7 @@ struct Example { scene: Handle>, } -impl<'a, 'b> SimpleState<'a, 'b> for Loading { +impl SimpleState for Loading { fn on_start(&mut self, data: StateData) { self.prefab = Some(data.world.exec(|loader: PrefabLoader| { loader.load("prefab/renderable.ron", RonFormat, (), &mut self.progress) @@ -52,7 +52,7 @@ impl<'a, 'b> SimpleState<'a, 'b> for Loading { }); } - fn update(&mut self, data: &mut StateData) -> SimpleTrans<'a, 'b> { + fn update(&mut self, data: &mut StateData) -> SimpleTrans { match self.progress.complete() { Completion::Failed => { println!("Failed loading assets: {:?}", self.progress.errors()); @@ -72,18 +72,14 @@ impl<'a, 'b> SimpleState<'a, 'b> for Loading { } } -impl<'a, 'b> SimpleState<'a, 'b> for Example { +impl SimpleState for Example { fn on_start(&mut self, data: StateData) { let StateData { world, .. } = data; world.create_entity().with(self.scene.clone()).build(); } - fn handle_event( - &mut self, - data: StateData, - event: StateEvent, - ) -> SimpleTrans<'a, 'b> { + fn handle_event(&mut self, data: StateData, event: StateEvent) -> SimpleTrans { let w = data.world; if let StateEvent::Window(event) = &event { // Exit if user hits Escape or closes the window diff --git a/examples/separate_sphere/main.rs b/examples/separate_sphere/main.rs index ba241731d1..a98cf2bfbf 100644 --- a/examples/separate_sphere/main.rs +++ b/examples/separate_sphere/main.rs @@ -14,7 +14,7 @@ type MyPrefabData = BasicScenePrefab; struct Example; -impl<'a, 'b> SimpleState<'a, 'b> for Example { +impl SimpleState for Example { fn on_start(&mut self, data: StateData) { let handle = data.world.exec(|loader: PrefabLoader| { loader.load("prefab/sphere.ron", RonFormat, (), ()) diff --git a/examples/simple_image/main.rs b/examples/simple_image/main.rs index cec757ed69..35ed25860d 100644 --- a/examples/simple_image/main.rs +++ b/examples/simple_image/main.rs @@ -14,7 +14,7 @@ use amethyst::{ struct Example; -impl<'a, 'b> SimpleState<'a, 'b> for Example { +impl SimpleState for Example { fn on_start(&mut self, data: StateData) { let world = data.world; let texture_handle = load_texture(world, "logo.png"); diff --git a/examples/sphere/main.rs b/examples/sphere/main.rs index 51417e9d47..cca983251d 100644 --- a/examples/sphere/main.rs +++ b/examples/sphere/main.rs @@ -14,7 +14,7 @@ type MyPrefabData = BasicScenePrefab>; struct Example; -impl<'a, 'b> SimpleState<'a, 'b> for Example { +impl SimpleState for Example { fn on_start(&mut self, data: StateData) { // Initialise the scene with an object, a light and a camera. let handle = data.world.exec(|loader: PrefabLoader| { diff --git a/examples/sphere_multisample/main.rs b/examples/sphere_multisample/main.rs index 8bb0cbecd0..de96cda05a 100644 --- a/examples/sphere_multisample/main.rs +++ b/examples/sphere_multisample/main.rs @@ -14,7 +14,7 @@ type MyPrefabData = BasicScenePrefab>; struct Example; -impl<'a, 'b> SimpleState<'a, 'b> for Example { +impl SimpleState for Example { fn on_start(&mut self, data: StateData) { // Initialise the scene with an object, a light and a camera. let handle = data.world.exec(|loader: PrefabLoader| { diff --git a/examples/spotlights/main.rs b/examples/spotlights/main.rs index 8156e4542a..4a2c5e2dba 100644 --- a/examples/spotlights/main.rs +++ b/examples/spotlights/main.rs @@ -12,7 +12,7 @@ type MyPrefabData = BasicScenePrefab>; struct Example; -impl<'a, 'b> SimpleState<'a, 'b> for Example { +impl SimpleState for Example { fn on_start(&mut self, data: StateData) { let handle = data.world.exec(|loader: PrefabLoader| { loader.load("prefab/spotlights_scene.ron", RonFormat, (), ()) diff --git a/examples/sprite_camera_follow/main.rs b/examples/sprite_camera_follow/main.rs index fe2c93e8df..511fa67824 100644 --- a/examples/sprite_camera_follow/main.rs +++ b/examples/sprite_camera_follow/main.rs @@ -123,7 +123,7 @@ fn init_camera(world: &mut World, parent: Entity) { struct Example; -impl<'a, 'b> SimpleState<'a, 'b> for Example { +impl SimpleState for Example { fn on_start(&mut self, data: StateData) { let world = data.world; let circle_sprite_sheet_handle = diff --git a/examples/sprites_ordered/main.rs b/examples/sprites_ordered/main.rs index a1f9bd4fd4..5e051f739d 100644 --- a/examples/sprites_ordered/main.rs +++ b/examples/sprites_ordered/main.rs @@ -86,7 +86,7 @@ impl Example { } } -impl<'a, 'b> SimpleState<'a, 'b> for Example { +impl SimpleState for Example { fn on_start(&mut self, data: StateData) { let StateData { world, .. } = data; @@ -96,11 +96,7 @@ impl<'a, 'b> SimpleState<'a, 'b> for Example { self.redraw_sprites(world); } - fn handle_event( - &mut self, - mut data: StateData, - event: StateEvent, - ) -> SimpleTrans<'a, 'b> { + fn handle_event(&mut self, mut data: StateData, event: StateEvent) -> SimpleTrans { if let StateEvent::Window(event) = &event { if is_close_requested(&event) || is_key_down(&event, VirtualKeyCode::Escape) { return Trans::Quit; diff --git a/examples/state_dispatcher/main.rs b/examples/state_dispatcher/main.rs index a301386854..775cfa644e 100644 --- a/examples/state_dispatcher/main.rs +++ b/examples/state_dispatcher/main.rs @@ -13,8 +13,8 @@ use std::marker::PhantomData; struct StateA; -impl SimpleState<'static, 'static> for StateA { - fn update(&mut self, data: &mut StateData) -> SimpleTrans<'static, 'static> { +impl SimpleState for StateA { + fn update(&mut self, data: &mut StateData) -> SimpleTrans { println!("StateA::update()"); // Shows how to push a `Trans` through the event queue. // If you do use TransQueue, you will be forced to use the 'static lifetime on your states. @@ -45,8 +45,8 @@ impl<'a> Default for StateB<'a> { } } -impl<'a> SimpleState<'static, 'static> for StateB<'a> { - fn update(&mut self, data: &mut StateData) -> SimpleTrans<'static, 'static> { +impl<'a> SimpleState for StateB<'a> { + fn update(&mut self, data: &mut StateData) -> SimpleTrans { println!("StateB::update()"); self.dispatcher.dispatch(&mut data.world.res); Trans::Quit diff --git a/examples/ui/main.rs b/examples/ui/main.rs index 3f1c73ca31..efe8d3bbb8 100644 --- a/examples/ui/main.rs +++ b/examples/ui/main.rs @@ -28,7 +28,7 @@ struct Example { fps_display: Option, } -impl<'a, 'b> SimpleState<'a, 'b> for Example { +impl SimpleState for Example { fn on_start(&mut self, data: StateData) { let StateData { world, .. } = data; // Initialise the scene with an object, a light and a camera. @@ -42,7 +42,7 @@ impl<'a, 'b> SimpleState<'a, 'b> for Example { }); } - fn handle_event(&mut self, _: StateData, event: StateEvent) -> SimpleTrans<'a, 'b> { + fn handle_event(&mut self, _: StateData, event: StateEvent) -> SimpleTrans { match &event { StateEvent::Window(event) => { if is_close_requested(&event) || is_key_down(&event, VirtualKeyCode::Escape) { @@ -61,7 +61,7 @@ impl<'a, 'b> SimpleState<'a, 'b> for Example { } } - fn update(&mut self, state_data: &mut StateData) -> SimpleTrans<'a, 'b> { + fn update(&mut self, state_data: &mut StateData) -> SimpleTrans { let StateData { world, .. } = state_data; if self.fps_display.is_none() { world.exec(|finder: UiFinder| { diff --git a/examples/window/main.rs b/examples/window/main.rs index 6364873c7d..fcc2b50d06 100644 --- a/examples/window/main.rs +++ b/examples/window/main.rs @@ -12,8 +12,8 @@ use amethyst::{ struct Example; -impl<'a, 'b> SimpleState<'a, 'b> for Example { - fn handle_event(&mut self, _: StateData, event: StateEvent) -> SimpleTrans<'a, 'b> { +impl SimpleState for Example { + fn handle_event(&mut self, _: StateData, event: StateEvent) -> SimpleTrans { if let StateEvent::Window(event) = event { if is_key_down(&event, VirtualKeyCode::Escape) { Trans::Quit diff --git a/src/app.rs b/src/app.rs index ba04487973..5826ba7b15 100644 --- a/src/app.rs +++ b/src/app.rs @@ -674,7 +674,7 @@ where /// .run(); /// /// struct LoadingState; - /// impl<'a, 'b> SimpleState<'a, 'b> for LoadingState { + /// impl SimpleState for LoadingState { /// fn on_start(&mut self, data: StateData) { /// let storage = data.world.read_resource(); /// diff --git a/src/game_data.rs b/src/game_data.rs index fd5d111456..2a40958696 100644 --- a/src/game_data.rs +++ b/src/game_data.rs @@ -15,7 +15,10 @@ pub trait DataInit { fn build(self, world: &mut World) -> T; } -/// Default game data +/// Default game data. +/// +/// The lifetimes are for the systems inside and can be `'static` unless a system has a borrowed +/// field. pub struct GameData<'a, 'b> { dispatcher: Dispatcher<'a, 'b>, } diff --git a/src/state.rs b/src/state.rs index f70a3e216f..4c8f04c28e 100644 --- a/src/state.rs +++ b/src/state.rs @@ -76,7 +76,7 @@ pub type EmptyTrans = Trans<(), StateEvent>; /// A simple default `Trans`. Made to be used with `SimpleState`. /// By default it contains a `GameData` as its `StateData` and doesn't have a custom event type. -pub type SimpleTrans<'a, 'b> = Trans, StateEvent>; +pub type SimpleTrans = Trans, StateEvent>; /// A trait which defines game states that can be used by the state machine. pub trait State { @@ -226,7 +226,7 @@ impl State<(), StateEvent> for T { } /// A simple `State` trait. It contains `GameData` as its `StateData` and no custom `StateEvent`. -pub trait SimpleState<'a, 'b> { +pub trait SimpleState { /// Executed when the game state begins. fn on_start(&mut self, _data: StateData<'_, GameData<'_, '_>>) {} @@ -244,7 +244,7 @@ pub trait SimpleState<'a, 'b> { &mut self, _data: StateData<'_, GameData<'_, '_>>, event: StateEvent, - ) -> SimpleTrans<'a, 'b> { + ) -> SimpleTrans { if let StateEvent::Window(event) = &event { if is_close_requested(&event) { Trans::Quit @@ -258,12 +258,12 @@ pub trait SimpleState<'a, 'b> { /// Executed repeatedly at stable, predictable intervals (1/60th of a second /// by default). - fn fixed_update(&mut self, _data: StateData<'_, GameData<'_, '_>>) -> SimpleTrans<'a, 'b> { + fn fixed_update(&mut self, _data: StateData<'_, GameData<'_, '_>>) -> SimpleTrans { Trans::None } /// Executed on every frame immediately, as fast as the engine will allow (taking into account the frame rate limit). - fn update(&mut self, _data: &mut StateData<'_, GameData<'_, '_>>) -> SimpleTrans<'a, 'b> { + fn update(&mut self, _data: &mut StateData<'_, GameData<'_, '_>>) -> SimpleTrans { Trans::None } @@ -279,7 +279,7 @@ pub trait SimpleState<'a, 'b> { fn shadow_update(&mut self, _data: StateData<'_, GameData<'_, '_>>) {} } -impl<'a, 'b, T: SimpleState<'a, 'b>> State, StateEvent> for T { +impl State, StateEvent> for T { //pub trait SimpleState<'a,'b>: State,()> { /// Executed when the game state begins. @@ -307,18 +307,18 @@ impl<'a, 'b, T: SimpleState<'a, 'b>> State, StateEvent> for T { &mut self, data: StateData<'_, GameData<'_, '_>>, event: StateEvent, - ) -> SimpleTrans<'a, 'b> { + ) -> SimpleTrans { self.handle_event(data, event) } /// Executed repeatedly at stable, predictable intervals (1/60th of a second /// by default). - fn fixed_update(&mut self, data: StateData<'_, GameData<'_, '_>>) -> SimpleTrans<'a, 'b> { + fn fixed_update(&mut self, data: StateData<'_, GameData<'_, '_>>) -> SimpleTrans { self.fixed_update(data) } /// Executed on every frame immediately, as fast as the engine will allow (taking into account the frame rate limit). - fn update(&mut self, mut data: StateData<'_, GameData<'_, '_>>) -> SimpleTrans<'a, 'b> { + fn update(&mut self, mut data: StateData<'_, GameData<'_, '_>>) -> SimpleTrans { let r = self.update(&mut data); data.data.update(&data.world); r