diff --git a/all-is-cubes-desktop/src/lib.rs b/all-is-cubes-desktop/src/lib.rs index 5a6f1b95e..f18da077a 100644 --- a/all-is-cubes-desktop/src/lib.rs +++ b/all-is-cubes-desktop/src/lib.rs @@ -1,3 +1,4 @@ +#![feature(async_closure)] #![feature(never_type)] //! Components for creating a desktop application that renders interactive [`all_is_cubes`] @@ -101,7 +102,7 @@ pub fn inner_main( .context("failed to configure session for recording")?; } - dsession.session.set_main_task(|mut ctx| async move { + dsession.session.set_main_task(async move |mut ctx| { let universe_result: Result = match universe_future.await { Ok(Ok(u)) => Ok(u), Ok(Err(e)) => { diff --git a/all-is-cubes-desktop/src/session.rs b/all-is-cubes-desktop/src/session.rs index 7b9d40693..4bb9ee1f6 100644 --- a/all-is-cubes-desktop/src/session.rs +++ b/all-is-cubes-desktop/src/session.rs @@ -9,7 +9,7 @@ use all_is_cubes::universe::Universe; use all_is_cubes::universe::UniverseStepInfo; use all_is_cubes::util::ErrorChain; use all_is_cubes_render::camera::Viewport; -use all_is_cubes_ui::apps::ExitMainTask; +use all_is_cubes_ui::apps::{ExitMainTask, MainTaskContext}; use crate::Session; @@ -145,25 +145,26 @@ impl DesktopSession { // TODO: Also make a way to do this that isn't replacing the main task, // or that defines a way for the existing main task to coordinate. - self.session.set_main_task(move |mut ctx| async move { - // TODO: Offer confirmation before replacing the current universe. - // TODO: Then open a progress-bar UI page while we load. - - match loader_task.await.unwrap() { - Ok(universe) => { - ctx.set_universe(universe); - } - Err(e) => { - ctx.show_modal_message(arcstr::format!( - "Failed to load file '{path}':\n{e}", - path = path.display(), - e = ErrorChain(&e), - )); + self.session + .set_main_task(async move |mut ctx: MainTaskContext| { + // TODO: Offer confirmation before replacing the current universe. + // TODO: Then open a progress-bar UI page while we load. + + match loader_task.await.unwrap() { + Ok(universe) => { + ctx.set_universe(universe); + } + Err(e) => { + ctx.show_modal_message(arcstr::format!( + "Failed to load file '{path}':\n{e}", + path = path.display(), + e = ErrorChain(&e), + )); + } } - } - ExitMainTask - }) + ExitMainTask + }) } /// Set the “fixed” window title — the portion of the title not determined by the universe, diff --git a/all-is-cubes-ui/src/apps/session.rs b/all-is-cubes-ui/src/apps/session.rs index ac27608e9..9a8b1d9fe 100644 --- a/all-is-cubes-ui/src/apps/session.rs +++ b/all-is-cubes-ui/src/apps/session.rs @@ -1370,7 +1370,7 @@ mod tests { let mut cameras = session.create_cameras(ListenableSource::constant(Viewport::ARBITRARY)); session.set_main_task({ let noticed_step = noticed_step.clone(); - move |mut ctx| async move { + async move |mut ctx: MainTaskContext| { eprintln!("main task: waiting for new universe"); let new_universe = recv.await.unwrap(); ctx.set_universe(new_universe); diff --git a/all-is-cubes-ui/src/lib.rs b/all-is-cubes-ui/src/lib.rs index 648e9ad8a..18801f36d 100644 --- a/all-is-cubes-ui/src/lib.rs +++ b/all-is-cubes-ui/src/lib.rs @@ -1,3 +1,4 @@ +#![feature(async_closure)] #![feature(never_type)] #![feature(noop_waker)] #![feature(precise_capturing)] diff --git a/test-renderers/tests/wgpu-render.rs b/test-renderers/tests/wgpu-render.rs index 80e51b93a..d985a36ef 100644 --- a/test-renderers/tests/wgpu-render.rs +++ b/test-renderers/tests/wgpu-render.rs @@ -1,5 +1,7 @@ //! Runs [`test_renderers::harness_main`] against [`all_is_cubes_gpu::in_wgpu`]. +#![feature(async_closure)] + use clap::Parser as _; use tokio::sync::OnceCell; @@ -29,7 +31,7 @@ async fn main() -> test_renderers::HarnessResult { RendererId::Wgpu, test_renderers::SuiteId::Renderers, test_renderers::test_cases::all_tests, - move || async move { get_factory().await.unwrap() }, + async move || get_factory().await.unwrap(), parallelism, ) .await