1
0
mirror of https://github.com/emilk/egui.git synced 2026-06-26 22:53:14 -04:00

Forbid uses of unwrap() in the code (#7795)

This commit is contained in:
Emil Ernerfeldt
2025-12-19 20:34:18 +01:00
committed by GitHub
parent 646fea2133
commit 7fe58bbfd4
44 changed files with 120 additions and 64 deletions

View File

@@ -791,6 +791,7 @@ impl Frame {
/// This function will take the ownership of your [`glow::Texture`], so please do not delete your [`glow::Texture`] after registering.
#[cfg(all(feature = "glow", not(target_arch = "wasm32")))]
pub fn register_native_glow_texture(&mut self, native: glow::Texture) -> egui::TextureId {
#[expect(clippy::unwrap_used)]
self.glow_register_native_texture.as_mut().unwrap()(native)
}

View File

@@ -376,6 +376,7 @@ impl EpiIntegration {
fn load_default_egui_icon() -> egui::IconData {
profiling::function_scope!();
#[expect(clippy::unwrap_used)]
crate::icon_data::from_png_bytes(&include_bytes!("../../data/icon.png")[..]).unwrap()
}

View File

@@ -5,7 +5,8 @@
//! There is a bunch of improvements we could do,
//! like removing a bunch of `unwraps`.
#![allow(clippy::undocumented_unsafe_blocks)]
#![expect(clippy::undocumented_unsafe_blocks)]
#![expect(clippy::unwrap_used)]
use std::{cell::RefCell, num::NonZeroU32, rc::Rc, sync::Arc, time::Instant};

View File

@@ -27,7 +27,10 @@ pub fn create_egui_context(storage: Option<&dyn crate::Storage>) -> egui::Contex
egui_ctx.options_mut(|o| {
// eframe supports multi-pass (Context::request_discard).
o.max_passes = 2.try_into().unwrap();
#[expect(clippy::unwrap_used)]
{
o.max_passes = 2.try_into().unwrap();
}
});
let memory = crate::native::epi_integration::load_egui_memory(storage).unwrap_or_default();

View File

@@ -23,7 +23,7 @@ impl Stopwatch {
}
pub fn pause(&mut self) {
let start = self.start.take().unwrap();
let start = self.start.take().expect("Stopwatch is not running");
let duration = start.elapsed();
self.total_time_ns += duration.as_nanos();
}

View File

@@ -1,6 +1,7 @@
//! [`egui`] bindings for web apps (compiling to WASM).
#![allow(clippy::missing_errors_doc)] // So many `-> Result<_, JsValue>`
#![expect(clippy::missing_errors_doc)] // So many `-> Result<_, JsValue>`
#![expect(clippy::unwrap_used)] // TODO(emilk): remove unwraps
mod app_runner;
mod backend;