Skip to content

Commit 10571e9

Browse files
authored
eframe::Result is now short for eframe::Result<()> (emilk#4706)
1 parent 07735a6 commit 10571e9

File tree

25 files changed

+33
-36
lines changed

25 files changed

+33
-36
lines changed

crates/eframe/src/lib.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ pub mod icon_data;
197197
/// ``` no_run
198198
/// use eframe::egui;
199199
///
200-
/// fn main() -> eframe::Result<()> {
200+
/// fn main() -> eframe::Result {
201201
/// let native_options = eframe::NativeOptions::default();
202202
/// eframe::run_native("MyApp", native_options, Box::new(|cc| Ok(Box::new(MyEguiApp::new(cc)))))
203203
/// }
@@ -233,7 +233,7 @@ pub fn run_native(
233233
app_name: &str,
234234
mut native_options: NativeOptions,
235235
app_creator: AppCreator,
236-
) -> Result<()> {
236+
) -> Result {
237237
#[cfg(not(feature = "__screenshot"))]
238238
assert!(
239239
std::env::var("EFRAME_SCREENSHOT_TO").is_err(),
@@ -278,7 +278,7 @@ pub fn run_native(
278278
///
279279
/// # Example
280280
/// ``` no_run
281-
/// fn main() -> eframe::Result<()> {
281+
/// fn main() -> eframe::Result {
282282
/// // Our application state:
283283
/// let mut name = "Arthur".to_owned();
284284
/// let mut age = 42;
@@ -310,7 +310,7 @@ pub fn run_simple_native(
310310
app_name: &str,
311311
native_options: NativeOptions,
312312
update_fun: impl FnMut(&egui::Context, &mut Frame) + 'static,
313-
) -> Result<()> {
313+
) -> Result {
314314
struct SimpleApp<U> {
315315
update_fun: U,
316316
}
@@ -445,7 +445,7 @@ impl std::fmt::Display for Error {
445445
}
446446

447447
/// Short for `Result<T, eframe::Error>`.
448-
pub type Result<T, E = Error> = std::result::Result<T, E>;
448+
pub type Result<T = (), E = Error> = std::result::Result<T, E>;
449449

450450
// ---------------------------------------------------------------------------
451451

crates/eframe/src/native/glow_integration.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1088,7 +1088,7 @@ impl GlutinWindowContext {
10881088
&mut self,
10891089
viewport_id: ViewportId,
10901090
event_loop: &EventLoopWindowTarget<UserEvent>,
1091-
) -> Result<()> {
1091+
) -> Result {
10921092
crate::profile_function!();
10931093

10941094
let viewport = self
@@ -1188,7 +1188,7 @@ impl GlutinWindowContext {
11881188
}
11891189

11901190
/// only applies for android. but we basically drop surface + window and make context not current
1191-
fn on_suspend(&mut self) -> Result<()> {
1191+
fn on_suspend(&mut self) -> Result {
11921192
log::debug!("received suspend event. dropping window and surface");
11931193
for viewport in self.viewports.values_mut() {
11941194
viewport.gl_surface = None;

crates/eframe/src/native/run.rs

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -60,10 +60,7 @@ fn with_event_loop<R>(
6060
}
6161

6262
#[cfg(not(target_os = "ios"))]
63-
fn run_and_return(
64-
event_loop: &mut EventLoop<UserEvent>,
65-
mut winit_app: impl WinitApp,
66-
) -> Result<()> {
63+
fn run_and_return(event_loop: &mut EventLoop<UserEvent>, mut winit_app: impl WinitApp) -> Result {
6764
use winit::{event_loop::ControlFlow, platform::run_on_demand::EventLoopExtRunOnDemand};
6865

6966
log::trace!("Entering the winit event loop (run_on_demand)…");
@@ -234,7 +231,7 @@ fn run_and_return(
234231
fn run_and_exit(
235232
event_loop: EventLoop<UserEvent>,
236233
mut winit_app: impl WinitApp + 'static,
237-
) -> Result<()> {
234+
) -> Result {
238235
use winit::event_loop::ControlFlow;
239236
log::trace!("Entering the winit event loop (run)…");
240237

@@ -390,7 +387,7 @@ pub fn run_glow(
390387
app_name: &str,
391388
mut native_options: epi::NativeOptions,
392389
app_creator: epi::AppCreator,
393-
) -> Result<()> {
390+
) -> Result {
394391
#![allow(clippy::needless_return_with_question_mark)] // False positive
395392

396393
use super::glow_integration::GlowWinitApp;
@@ -415,7 +412,7 @@ pub fn run_wgpu(
415412
app_name: &str,
416413
mut native_options: epi::NativeOptions,
417414
app_creator: epi::AppCreator,
418-
) -> Result<()> {
415+
) -> Result {
419416
#![allow(clippy::needless_return_with_question_mark)] // False positive
420417

421418
use super::wgpu_integration::WgpuWinitApp;

crates/egui_demo_app/src/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
#![allow(clippy::never_loop)] // False positive
66

77
// When compiling natively:
8-
fn main() -> Result<(), eframe::Error> {
8+
fn main() -> eframe::Result {
99
for arg in std::env::args().skip(1) {
1010
match arg.as_str() {
1111
"--profile" => {

examples/confirm_exit/src/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
use eframe::egui;
55

6-
fn main() -> Result<(), eframe::Error> {
6+
fn main() -> eframe::Result {
77
env_logger::init(); // Log to stderr (if you run with `RUST_LOG=debug`).
88
let options = eframe::NativeOptions {
99
viewport: egui::ViewportBuilder::default().with_inner_size([320.0, 240.0]),

examples/custom_3d_glow/src/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ use eframe::{egui, egui_glow, glow};
88
use egui::mutex::Mutex;
99
use std::sync::Arc;
1010

11-
fn main() -> Result<(), eframe::Error> {
11+
fn main() -> eframe::Result {
1212
env_logger::init(); // Log to stderr (if you run with `RUST_LOG=debug`).
1313
let options = eframe::NativeOptions {
1414
viewport: egui::ViewportBuilder::default().with_inner_size([350.0, 380.0]),

examples/custom_font/src/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
use eframe::egui;
55

6-
fn main() -> Result<(), eframe::Error> {
6+
fn main() -> eframe::Result {
77
env_logger::init(); // Log to stderr (if you run with `RUST_LOG=debug`).
88
let options = eframe::NativeOptions {
99
viewport: egui::ViewportBuilder::default().with_inner_size([320.0, 240.0]),

examples/custom_font_style/src/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
use eframe::egui;
55
use egui::{FontFamily, FontId, RichText, TextStyle};
66

7-
fn main() -> Result<(), eframe::Error> {
7+
fn main() -> eframe::Result {
88
env_logger::init(); // Log to stderr (if you run with `RUST_LOG=debug`).
99
let options = eframe::NativeOptions::default();
1010

examples/custom_keypad/src/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use eframe::egui;
55
mod keypad;
66
use keypad::Keypad;
77

8-
fn main() -> Result<(), eframe::Error> {
8+
fn main() -> eframe::Result {
99
env_logger::init(); // Log to stderr (if you run with `RUST_LOG=debug`).
1010
let options = eframe::NativeOptions {
1111
viewport: egui::ViewportBuilder::default().with_inner_size([640.0, 480.0]),

examples/custom_plot_manipulation/src/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
use eframe::egui::{self, DragValue, Event, Vec2};
66
use egui_plot::{Legend, Line, PlotPoints};
77

8-
fn main() -> Result<(), eframe::Error> {
8+
fn main() -> eframe::Result {
99
env_logger::init(); // Log to stderr (if you run with `RUST_LOG=debug`).
1010
let options = eframe::NativeOptions::default();
1111
eframe::run_native(

0 commit comments

Comments
 (0)