`eframe::Result` is now short for `eframe::Result<()>` (#4706)

This commit is contained in:
Emil Ernerfeldt 2024-06-25 13:31:42 +02:00 committed by GitHub
parent 07735a6465
commit 10571e9da5
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
25 changed files with 33 additions and 36 deletions

View File

@ -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)))))
/// }
@ -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(),
@ -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;
@ -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,
}
@ -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>;
// ---------------------------------------------------------------------------

View File

@ -1088,7 +1088,7 @@ impl GlutinWindowContext {
&mut self,
viewport_id: ViewportId,
event_loop: &EventLoopWindowTarget<UserEvent>,
) -> Result<()> {
) -> Result {
crate::profile_function!();
let viewport = self
@ -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;

View File

@ -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)…");
@ -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)…");
@ -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;
@ -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;

View File

@ -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" => {

View File

@ -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]),

View File

@ -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]),

View File

@ -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]),

View File

@ -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();

View File

@ -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]),

View File

@ -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(

View File

@ -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()

View File

@ -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()

View File

@ -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]),

View File

@ -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]),

View File

@ -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 {

View File

@ -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]),

View File

@ -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(

View File

@ -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]),

View File

@ -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!

View File

@ -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 {

View File

@ -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,

View File

@ -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") {

View File

@ -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.]),

View File

@ -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();

View File

@ -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]),