Skip to content

Commit

Permalink
eframe::Result: default first argument is ()
Browse files Browse the repository at this point in the history
  • Loading branch information
emilk committed Jun 25, 2024
1 parent 07735a6 commit b71625b
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 16 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 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

0 comments on commit b71625b

Please sign in to comment.