dont force static lifetime on appplugin string

This commit is contained in:
Carter Anderson 2020-04-04 13:00:52 -07:00
parent ef8c85f0c7
commit 4c3af427e9
11 changed files with 15 additions and 15 deletions

View File

@ -1,5 +1,5 @@
use bevy::{ use bevy::{
app::schedule_runner::{RunMode, ScheduleRunner}, app::schedule_runner::{RunMode, ScheduleRunnerPlugin},
prelude::*, prelude::*,
}; };
use std::time::Duration; use std::time::Duration;
@ -7,7 +7,7 @@ use std::time::Duration;
fn main() { fn main() {
println!("This app runs once:"); println!("This app runs once:");
App::build() App::build()
.add_plugin(ScheduleRunner { .add_plugin(ScheduleRunnerPlugin {
run_mode: RunMode::Once, run_mode: RunMode::Once,
}) })
.add_system(hello_world_system()) .add_system(hello_world_system())
@ -15,7 +15,7 @@ fn main() {
println!("This app loops forever at 60 fps:"); println!("This app loops forever at 60 fps:");
App::build() App::build()
.add_plugin(ScheduleRunner { .add_plugin(ScheduleRunnerPlugin {
run_mode: RunMode::Loop { run_mode: RunMode::Loop {
wait: Some(Duration::from_secs_f64(1.0 / 60.0)), wait: Some(Duration::from_secs_f64(1.0 / 60.0)),
}, },

View File

@ -8,7 +8,7 @@ impl AppPlugin for ExamplePlugin {
app_builder.setup(setup) app_builder.setup(setup)
} }
fn name(&self) -> &'static str { fn name(&self) -> &str {
"example" "example"
} }
} }

View File

@ -4,7 +4,7 @@ use std::any::Any;
pub trait AppPlugin: Any + Send + Sync { pub trait AppPlugin: Any + Send + Sync {
fn build(&self, app: AppBuilder) -> AppBuilder; fn build(&self, app: AppBuilder) -> AppBuilder;
fn name(&self) -> &'static str; fn name(&self) -> &str;
} }
pub type CreateAppPlugin = unsafe fn() -> *mut dyn AppPlugin; pub type CreateAppPlugin = unsafe fn() -> *mut dyn AppPlugin;

View File

@ -17,11 +17,11 @@ impl Default for RunMode {
} }
#[derive(Default)] #[derive(Default)]
pub struct ScheduleRunner { pub struct ScheduleRunnerPlugin {
pub run_mode: RunMode, pub run_mode: RunMode,
} }
impl AppPlugin for ScheduleRunner { impl AppPlugin for ScheduleRunnerPlugin {
fn build(&self, app: AppBuilder) -> AppBuilder { fn build(&self, app: AppBuilder) -> AppBuilder {
let run_mode = self.run_mode; let run_mode = self.run_mode;
app.set_runner(move |mut app: App| match run_mode { app.set_runner(move |mut app: App| match run_mode {
@ -36,7 +36,7 @@ impl AppPlugin for ScheduleRunner {
}, },
}) })
} }
fn name(&self) -> &'static str { fn name(&self) -> &str {
"ScheduleRun" "ScheduleRun"
} }
} }

View File

@ -14,7 +14,7 @@ impl AppPlugin for CorePlugin {
app.add_resource(Time::new()) app.add_resource(Time::new())
} }
fn name(&self) -> &'static str { fn name(&self) -> &str {
"Core" "Core"
} }
} }

View File

@ -36,7 +36,7 @@ impl AppPlugin for DiagnosticsPlugin {
app app
} }
fn name(&self) -> &'static str { fn name(&self) -> &str {
"Diagnostics" "Diagnostics"
} }
} }

View File

@ -70,7 +70,7 @@ impl AppPlugin for RenderPlugin {
app app
} }
fn name(&self) -> &'static str { fn name(&self) -> &str {
"Render" "Render"
} }
} }

View File

@ -24,7 +24,7 @@ impl AppPlugin for WgpuRendererPlugin {
let render_system = wgpu_render_system(&app.resources); let render_system = wgpu_render_system(&app.resources);
app.add_thread_local_to_stage(system_stage::RENDER, render_system) app.add_thread_local_to_stage(system_stage::RENDER, render_system)
} }
fn name(&self) -> &'static str { fn name(&self) -> &str {
"WgpuRenderer" "WgpuRenderer"
} }
} }

View File

@ -17,7 +17,7 @@ impl AppPlugin for UiPlugin {
fn build(&self, app: AppBuilder) -> AppBuilder { fn build(&self, app: AppBuilder) -> AppBuilder {
app.add_system(ui_update_system()) app.add_system(ui_update_system())
} }
fn name(&self) -> &'static str { fn name(&self) -> &str {
"UI" "UI"
} }
} }

View File

@ -34,7 +34,7 @@ impl AppPlugin for WindowPlugin {
app app
} }
fn name(&self) -> &'static str { fn name(&self) -> &str {
"Window" "Window"
} }
} }

View File

@ -19,7 +19,7 @@ impl AppPlugin for WinitPlugin {
.set_runner(winit_runner) .set_runner(winit_runner)
} }
fn name(&self) -> &'static str { fn name(&self) -> &str {
"Winit" "Winit"
} }
} }