mirror of
https://github.com/emilk/egui.git
synced 2026-09-02 06:40:06 -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.
|
#![warn(missing_docs)] // Let's keep `epi` well-documented.
|
||||||
|
|
||||||
#[cfg(target_arch = "wasm32")]
|
|
||||||
use std::any::Any;
|
|
||||||
|
|
||||||
#[cfg(not(target_arch = "wasm32"))]
|
#[cfg(not(target_arch = "wasm32"))]
|
||||||
#[cfg(any(feature = "glow", feature = "wgpu_no_default_features"))]
|
#[cfg(any(feature = "glow", feature = "wgpu_no_default_features"))]
|
||||||
pub use crate::native::winit_integration::UserEvent;
|
pub use crate::native::winit_integration::UserEvent;
|
||||||
@@ -176,26 +173,6 @@ pub trait App {
|
|||||||
_ = (ctx, frame);
|
_ = (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.
|
/// Called on shutdown, and perhaps at regular intervals. Allows you to save state.
|
||||||
///
|
///
|
||||||
/// Only called when the "persistence" feature is enabled.
|
/// 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`].
|
/// This will panic if your app does not implement [`App::as_any_mut`].
|
||||||
pub fn app_mut<ConcreteApp: 'static + App>(&mut self) -> &mut ConcreteApp {
|
pub fn app_mut<ConcreteApp: 'static + App>(&mut self) -> &mut ConcreteApp {
|
||||||
self.app
|
(self.app.as_mut() as &mut dyn std::any::Any)
|
||||||
.as_any_mut()
|
|
||||||
.expect("Your app must implement `as_any_mut`, but it doesn't")
|
|
||||||
.downcast_mut::<ConcreteApp>()
|
.downcast_mut::<ConcreteApp>()
|
||||||
.expect("app_mut got the wrong type of App")
|
.expect("app_mut got the wrong type of App")
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,9 +3,6 @@ use egui_demo_lib::{DemoWindows, is_mobile};
|
|||||||
#[cfg(feature = "glow")]
|
#[cfg(feature = "glow")]
|
||||||
use eframe::glow;
|
use eframe::glow;
|
||||||
|
|
||||||
#[cfg(target_arch = "wasm32")]
|
|
||||||
use core::any::Any;
|
|
||||||
|
|
||||||
use crate::DemoApp;
|
use crate::DemoApp;
|
||||||
|
|
||||||
#[derive(Default)]
|
#[derive(Default)]
|
||||||
@@ -323,11 +320,6 @@ impl eframe::App for WrapApp {
|
|||||||
custom3d.on_exit(gl);
|
custom3d.on_exit(gl);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(target_arch = "wasm32")]
|
|
||||||
fn as_any_mut(&mut self) -> Option<&mut dyn Any> {
|
|
||||||
Some(&mut *self)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl WrapApp {
|
impl WrapApp {
|
||||||
|
|||||||
Reference in New Issue
Block a user