From e03d20feb7ff9c14588a9c537f5c7ddf34e86eca Mon Sep 17 00:00:00 2001 From: Andreas Reich Date: Sat, 5 Oct 2024 17:50:18 +0200 Subject: [PATCH] fist rust warnings & bypassed `is_active` implementation --- src/lib.rs | 2 -- src/os/wasm/mod.rs | 12 ++++++------ src/rate.rs | 2 ++ 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 6d72cce..cb22688 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -27,8 +27,6 @@ use std::{ffi::c_void, fmt, time::Duration}; #[cfg(target_arch = "wasm32")] use std::panic; -#[cfg(target_arch = "wasm32")] -use web_sys::HtmlElement; #[cfg(target_os = "macos")] use os::macos as imp; diff --git a/src/os/wasm/mod.rs b/src/os/wasm/mod.rs index be75649..d11c729 100644 --- a/src/os/wasm/mod.rs +++ b/src/os/wasm/mod.rs @@ -184,7 +184,7 @@ impl Window { closure.forget(); } - let mut window = Window { + Ok(Window { width: width as u32, height: height as u32, bg_color: 0, @@ -196,9 +196,7 @@ impl Window { menu_counter: MenuHandle(0), menus: Vec::new(), raw_handle_id, - }; - - Ok(window) + }) } fn create_2d_context(&self) -> CanvasRenderingContext2d { @@ -426,8 +424,10 @@ impl Window { #[inline] pub fn is_active(&mut self) -> bool { - let document = window().unwrap().document().unwrap(); - document.active_element().unwrap_or(return false) == **self.canvas + window() + .and_then(|window| window.document()) + .and_then(|document| document.active_element()) + .map_or(false, |element| element == **self.canvas) } #[inline] diff --git a/src/rate.rs b/src/rate.rs index ab340dd..39ef936 100644 --- a/src/rate.rs +++ b/src/rate.rs @@ -5,11 +5,13 @@ use instant::{Duration, Instant}; #[cfg(not(target_arch = "wasm32"))] use std::time::{Duration, Instant}; +#[cfg_attr(target_arch = "wasm32", allow(unused))] pub struct UpdateRate { target_rate: Option, prev_time: Instant, } +#[cfg_attr(target_arch = "wasm32", allow(unused))] impl UpdateRate { pub fn new() -> UpdateRate { UpdateRate {