mirror of
https://github.com/emilk/egui.git
synced 2026-06-26 22:53:14 -04:00
Remove fn as_any as it is no longer needed
This commit is contained in:
@@ -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<dyn App>` -> `Box<dyn Any>` 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.
|
||||
|
||||
@@ -184,9 +184,7 @@ impl AppRunner {
|
||||
///
|
||||
/// This will panic if your app does not implement [`App::as_any_mut`].
|
||||
pub fn app_mut<ConcreteApp: 'static + App>(&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::<ConcreteApp>()
|
||||
.expect("app_mut got the wrong type of App")
|
||||
}
|
||||
|
||||
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user