mirror of
https://github.com/emilk/egui.git
synced 2026-08-30 13:20:05 -04:00
Support returning errors when creating the app (#4565)
The closure passed to `eframe::run_native` now returns a `Result`, allowing you to return an error during app creation, which will be returned to the caller of `run_native`. This means you need to wrap your `Box::new(MyApp::new(…))` in an `Ok(…)`. * Closes https://github.com/emilk/egui/issues/4474
This commit is contained in:
@@ -23,7 +23,7 @@ fn main() -> Result<(), eframe::Error> {
|
||||
eframe::run_native(
|
||||
"First Window",
|
||||
options.clone(),
|
||||
Box::new(|_cc| Box::new(MyApp { has_next: true })),
|
||||
Box::new(|_cc| Ok(Box::new(MyApp { has_next: true }))),
|
||||
)?;
|
||||
|
||||
std::thread::sleep(std::time::Duration::from_secs(2));
|
||||
@@ -32,7 +32,7 @@ fn main() -> Result<(), eframe::Error> {
|
||||
eframe::run_native(
|
||||
"Second Window",
|
||||
options.clone(),
|
||||
Box::new(|_cc| Box::new(MyApp { has_next: true })),
|
||||
Box::new(|_cc| Ok(Box::new(MyApp { has_next: true }))),
|
||||
)?;
|
||||
|
||||
std::thread::sleep(std::time::Duration::from_secs(2));
|
||||
@@ -41,7 +41,7 @@ fn main() -> Result<(), eframe::Error> {
|
||||
eframe::run_native(
|
||||
"Third Window",
|
||||
options,
|
||||
Box::new(|_cc| Box::new(MyApp { has_next: false })),
|
||||
Box::new(|_cc| Ok(Box::new(MyApp { has_next: false }))),
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user