Skip to content

Commit

Permalink
eframe::Result is now short for eframe::Result<()> (emilk#4706)
Browse files Browse the repository at this point in the history
  • Loading branch information
emilk authored and hacknus committed Oct 30, 2024
1 parent 4a9156d commit db3a181
Show file tree
Hide file tree
Showing 25 changed files with 33 additions and 36 deletions.
10 changes: 5 additions & 5 deletions crates/eframe/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ pub mod icon_data;
/// ``` no_run
/// use eframe::egui;
///
/// fn main() -> eframe::Result<()> {
/// fn main() -> eframe::Result {
/// let native_options = eframe::NativeOptions::default();
/// eframe::run_native("MyApp", native_options, Box::new(|cc| Ok(Box::new(MyEguiApp::new(cc)))))
/// }
Expand Down Expand Up @@ -233,7 +233,7 @@ pub fn run_native(
app_name: &str,
mut native_options: NativeOptions,
app_creator: AppCreator,
) -> Result<()> {
) -> Result {
#[cfg(not(feature = "__screenshot"))]
assert!(
std::env::var("EFRAME_SCREENSHOT_TO").is_err(),
Expand Down Expand Up @@ -278,7 +278,7 @@ pub fn run_native(
///
/// # Example
/// ``` no_run
/// fn main() -> eframe::Result<()> {
/// fn main() -> eframe::Result {
/// // Our application state:
/// let mut name = "Arthur".to_owned();
/// let mut age = 42;
Expand Down Expand Up @@ -310,7 +310,7 @@ pub fn run_simple_native(
app_name: &str,
native_options: NativeOptions,
update_fun: impl FnMut(&egui::Context, &mut Frame) + 'static,
) -> Result<()> {
) -> Result {
struct SimpleApp<U> {
update_fun: U,
}
Expand Down Expand Up @@ -445,7 +445,7 @@ impl std::fmt::Display for Error {
}

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

// ---------------------------------------------------------------------------

Expand Down
4 changes: 2 additions & 2 deletions crates/eframe/src/native/glow_integration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1088,7 +1088,7 @@ impl GlutinWindowContext {
&mut self,
viewport_id: ViewportId,
event_loop: &EventLoopWindowTarget<UserEvent>,
) -> Result<()> {
) -> Result {
crate::profile_function!();

let viewport = self
Expand Down Expand Up @@ -1188,7 +1188,7 @@ impl GlutinWindowContext {
}

/// only applies for android. but we basically drop surface + window and make context not current
fn on_suspend(&mut self) -> Result<()> {
fn on_suspend(&mut self) -> Result {
log::debug!("received suspend event. dropping window and surface");
for viewport in self.viewports.values_mut() {
viewport.gl_surface = None;
Expand Down
11 changes: 4 additions & 7 deletions crates/eframe/src/native/run.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,7 @@ fn with_event_loop<R>(
}

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

log::trace!("Entering the winit event loop (run_on_demand)…");
Expand Down Expand Up @@ -234,7 +231,7 @@ fn run_and_return(
fn run_and_exit(
event_loop: EventLoop<UserEvent>,
mut winit_app: impl WinitApp + 'static,
) -> Result<()> {
) -> Result {
use winit::event_loop::ControlFlow;
log::trace!("Entering the winit event loop (run)…");

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

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

use super::wgpu_integration::WgpuWinitApp;
Expand Down
2 changes: 1 addition & 1 deletion crates/egui_demo_app/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#![allow(clippy::never_loop)] // False positive

// When compiling natively:
fn main() -> Result<(), eframe::Error> {
fn main() -> eframe::Result {
for arg in std::env::args().skip(1) {
match arg.as_str() {
"--profile" => {
Expand Down
2 changes: 1 addition & 1 deletion examples/confirm_exit/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

use eframe::egui;

fn main() -> Result<(), eframe::Error> {
fn main() -> eframe::Result {
env_logger::init(); // Log to stderr (if you run with `RUST_LOG=debug`).
let options = eframe::NativeOptions {
viewport: egui::ViewportBuilder::default().with_inner_size([320.0, 240.0]),
Expand Down
2 changes: 1 addition & 1 deletion examples/custom_3d_glow/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use eframe::{egui, egui_glow, glow};
use egui::mutex::Mutex;
use std::sync::Arc;

fn main() -> Result<(), eframe::Error> {
fn main() -> eframe::Result {
env_logger::init(); // Log to stderr (if you run with `RUST_LOG=debug`).
let options = eframe::NativeOptions {
viewport: egui::ViewportBuilder::default().with_inner_size([350.0, 380.0]),
Expand Down
2 changes: 1 addition & 1 deletion examples/custom_font/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

use eframe::egui;

fn main() -> Result<(), eframe::Error> {
fn main() -> eframe::Result {
env_logger::init(); // Log to stderr (if you run with `RUST_LOG=debug`).
let options = eframe::NativeOptions {
viewport: egui::ViewportBuilder::default().with_inner_size([320.0, 240.0]),
Expand Down
2 changes: 1 addition & 1 deletion examples/custom_font_style/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
use eframe::egui;
use egui::{FontFamily, FontId, RichText, TextStyle};

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

Expand Down
2 changes: 1 addition & 1 deletion examples/custom_keypad/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use eframe::egui;
mod keypad;
use keypad::Keypad;

fn main() -> Result<(), eframe::Error> {
fn main() -> eframe::Result {
env_logger::init(); // Log to stderr (if you run with `RUST_LOG=debug`).
let options = eframe::NativeOptions {
viewport: egui::ViewportBuilder::default().with_inner_size([640.0, 480.0]),
Expand Down
2 changes: 1 addition & 1 deletion examples/custom_plot_manipulation/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
use eframe::egui::{self, DragValue, Event, Vec2};
use egui_plot::{Legend, Line, PlotPoints};

fn main() -> Result<(), eframe::Error> {
fn main() -> eframe::Result {
env_logger::init(); // Log to stderr (if you run with `RUST_LOG=debug`).
let options = eframe::NativeOptions::default();
eframe::run_native(
Expand Down
2 changes: 1 addition & 1 deletion examples/custom_window_frame/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

use eframe::egui::{self, ViewportCommand};

fn main() -> Result<(), eframe::Error> {
fn main() -> eframe::Result {
env_logger::init(); // Log to stderr (if you run with `RUST_LOG=debug`).
let options = eframe::NativeOptions {
viewport: egui::ViewportBuilder::default()
Expand Down
2 changes: 1 addition & 1 deletion examples/file_dialog/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

use eframe::egui;

fn main() -> Result<(), eframe::Error> {
fn main() -> eframe::Result {
env_logger::init(); // Log to stderr (if you run with `RUST_LOG=debug`).
let options = eframe::NativeOptions {
viewport: egui::ViewportBuilder::default()
Expand Down
2 changes: 1 addition & 1 deletion examples/hello_world/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

use eframe::egui;

fn main() -> Result<(), eframe::Error> {
fn main() -> eframe::Result {
env_logger::init(); // Log to stderr (if you run with `RUST_LOG=debug`).
let options = eframe::NativeOptions {
viewport: egui::ViewportBuilder::default().with_inner_size([320.0, 240.0]),
Expand Down
2 changes: 1 addition & 1 deletion examples/hello_world_par/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use std::thread::JoinHandle;

use eframe::egui;

fn main() -> Result<(), eframe::Error> {
fn main() -> eframe::Result {
env_logger::init(); // Log to stderr (if you run with `RUST_LOG=debug`).
let options = eframe::NativeOptions {
viewport: egui::ViewportBuilder::default().with_inner_size([1024.0, 768.0]),
Expand Down
2 changes: 1 addition & 1 deletion examples/hello_world_simple/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

use eframe::egui;

fn main() -> Result<(), eframe::Error> {
fn main() -> eframe::Result {
env_logger::init(); // Log to stderr (if you run with `RUST_LOG=debug`).

let options = eframe::NativeOptions {
Expand Down
2 changes: 1 addition & 1 deletion examples/images/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

use eframe::egui;

fn main() -> Result<(), eframe::Error> {
fn main() -> eframe::Result {
env_logger::init(); // Log to stderr (if you run with `RUST_LOG=debug`).
let options = eframe::NativeOptions {
viewport: egui::ViewportBuilder::default().with_inner_size([600.0, 800.0]),
Expand Down
2 changes: 1 addition & 1 deletion examples/keyboard_events/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
use eframe::egui;
use egui::*;

fn main() -> Result<(), eframe::Error> {
fn main() -> eframe::Result {
env_logger::init(); // Log to stderr (if you run with `RUST_LOG=debug`).
let options = eframe::NativeOptions::default();
eframe::run_native(
Expand Down
2 changes: 1 addition & 1 deletion examples/multiple_viewports/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use std::sync::{

use eframe::egui;

fn main() -> Result<(), eframe::Error> {
fn main() -> eframe::Result {
env_logger::init(); // Log to stderr (if you run with `RUST_LOG=debug`).
let options = eframe::NativeOptions {
viewport: egui::ViewportBuilder::default().with_inner_size([320.0, 240.0]),
Expand Down
2 changes: 1 addition & 1 deletion examples/puffin_profiler/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use std::sync::{

use eframe::egui;

fn main() -> Result<(), eframe::Error> {
fn main() -> eframe::Result {
env_logger::init(); // Log to stderr (if you run with `RUST_LOG=debug`).
start_puffin_server(); // NOTE: you may only want to call this if the users specifies some flag or clicks a button!

Expand Down
2 changes: 1 addition & 1 deletion examples/save_plot/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
use eframe::egui;
use egui_plot::{Legend, Line, Plot, PlotPoints};

fn main() -> Result<(), eframe::Error> {
fn main() -> eframe::Result {
env_logger::init(); // Log to stderr (if you run with `RUST_LOG=debug`).

let options = eframe::NativeOptions {
Expand Down
2 changes: 1 addition & 1 deletion examples/screenshot/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use std::sync::Arc;

use eframe::egui::{self, ColorImage};

fn main() -> Result<(), eframe::Error> {
fn main() -> eframe::Result {
env_logger::init(); // Log to stderr (if you run with `RUST_LOG=debug`).
let options = eframe::NativeOptions {
renderer: eframe::Renderer::Wgpu,
Expand Down
2 changes: 1 addition & 1 deletion examples/serial_windows/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

use eframe::egui;

fn main() -> Result<(), eframe::Error> {
fn main() -> eframe::Result {
env_logger::init(); // Log to stderr (if you run with `RUST_LOG=debug`).

if cfg!(target_os = "macos") {
Expand Down
2 changes: 1 addition & 1 deletion examples/user_attention/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use egui::{Button, CentralPanel, Context, UserAttentionType};

use std::time::{Duration, SystemTime};

fn main() -> eframe::Result<()> {
fn main() -> eframe::Result {
env_logger::init(); // Log to stderr (if you run with `RUST_LOG=debug`).
let native_options = NativeOptions {
viewport: egui::ViewportBuilder::default().with_inner_size([400., 200.]),
Expand Down
2 changes: 1 addition & 1 deletion tests/test_size_pass/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

use eframe::egui;

fn main() -> eframe::Result<()> {
fn main() -> eframe::Result {
env_logger::init(); // Use `RUST_LOG=debug` to see logs.

let options = eframe::NativeOptions::default();
Expand Down
2 changes: 1 addition & 1 deletion tests/test_ui_stack/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use eframe::egui;
use eframe::egui::{Rangef, Shape, UiKind};
use egui_extras::Column;

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

0 comments on commit db3a181

Please sign in to comment.