diff --git a/crates/eframe/src/epi.rs b/crates/eframe/src/epi.rs index c37dc1cf6..ccc120707 100644 --- a/crates/eframe/src/epi.rs +++ b/crates/eframe/src/epi.rs @@ -6,9 +6,6 @@ #![warn(missing_docs)] // Let's keep `epi` well-documented. -#[cfg(target_arch = "wasm32")] -use std::any::Any; - #[cfg(not(target_arch = "wasm32"))] #[cfg(any(feature = "glow", feature = "wgpu_no_default_features"))] pub use crate::native::winit_integration::UserEvent; @@ -176,26 +173,6 @@ pub trait App { _ = (ctx, frame); } - /// Get a handle to the app. - /// - /// Can be used from web to interact or other external context. - /// - /// You need to implement this if you want to be able to access the application from JS using [`crate::WebRunner::app_mut`]. - /// - /// This is needed because downcasting `Box` -> `Box` to get &`ConcreteApp` is not simple in current rust. - /// - /// Just copy-paste this as your implementation: - /// ```ignore - /// #[cfg(target_arch = "wasm32")] - /// fn as_any_mut(&mut self) -> Option<&mut dyn std::any::Any> { - /// Some(&mut *self) - /// } - /// ``` - #[cfg(target_arch = "wasm32")] - fn as_any_mut(&mut self) -> Option<&mut dyn Any> { - None - } - /// Called on shutdown, and perhaps at regular intervals. Allows you to save state. /// /// Only called when the "persistence" feature is enabled. diff --git a/crates/eframe/src/web/app_runner.rs b/crates/eframe/src/web/app_runner.rs index 11654135d..e915a9952 100644 --- a/crates/eframe/src/web/app_runner.rs +++ b/crates/eframe/src/web/app_runner.rs @@ -184,9 +184,7 @@ impl AppRunner { /// /// This will panic if your app does not implement [`App::as_any_mut`]. pub fn app_mut(&mut self) -> &mut ConcreteApp { - self.app - .as_any_mut() - .expect("Your app must implement `as_any_mut`, but it doesn't") + (self.app.as_mut() as &mut dyn std::any::Any) .downcast_mut::() .expect("app_mut got the wrong type of App") } diff --git a/crates/egui_demo_app/src/wrap_app.rs b/crates/egui_demo_app/src/wrap_app.rs index 5dcc89a3e..ba572ea8d 100644 --- a/crates/egui_demo_app/src/wrap_app.rs +++ b/crates/egui_demo_app/src/wrap_app.rs @@ -3,9 +3,6 @@ use egui_demo_lib::{DemoWindows, is_mobile}; #[cfg(feature = "glow")] use eframe::glow; -#[cfg(target_arch = "wasm32")] -use core::any::Any; - use crate::DemoApp; #[derive(Default)] @@ -323,11 +320,6 @@ impl eframe::App for WrapApp { custom3d.on_exit(gl); } } - - #[cfg(target_arch = "wasm32")] - fn as_any_mut(&mut self) -> Option<&mut dyn Any> { - Some(&mut *self) - } } impl WrapApp {