diff --git a/src/use_mouse.rs b/src/use_mouse.rs index 63b4d0c..1c65547 100644 --- a/src/use_mouse.rs +++ b/src/use_mouse.rs @@ -109,11 +109,10 @@ where move |event: web_sys::MouseEvent| { let result = coord_type.extract_mouse_coords(&event); - if let (x, y) = result { - set_x.set(x); - set_y.set(y); - set_source_type.set(UseMouseSourceType::Mouse); - } + let (x, y) = result; + set_x.set(x); + set_y.set(y); + set_source_type.set(UseMouseSourceType::Mouse); } }; @@ -138,11 +137,10 @@ where .expect("Just checked that there's at least on touch"), ); - if let (x, y) = result { - set_x.set(x); - set_y.set(y); - set_source_type.set(UseMouseSourceType::Touch); - } + let (x, y) = result; + set_x.set(x); + set_y.set(y); + set_source_type.set(UseMouseSourceType::Touch); } } }; @@ -234,7 +232,7 @@ where impl Default for UseMouseOptions { fn default() -> Self { Self { - coord_type: UseMouseCoordType::::default(), + coord_type: UseMouseCoordType::default(), target: use_window(), touch: true, reset_on_touch_ends: false, @@ -254,7 +252,7 @@ pub enum UseMouseCoordType { Custom(E), } -impl Default for UseMouseCoordType { +impl Default for UseMouseCoordType { fn default() -> Self { Self::Page } diff --git a/src/use_mouse_in_element.rs b/src/use_mouse_in_element.rs index 29ad0f9..df80b2e 100644 --- a/src/use_mouse_in_element.rs +++ b/src/use_mouse_in_element.rs @@ -1,11 +1,12 @@ use crate::core::{ElementMaybeSignal, Position}; use crate::{ use_mouse_with_options, use_window, UseMouseCoordType, UseMouseEventExtractor, - UseMouseEventExtractorDefault, UseMouseOptions, UseMouseReturn, UseMouseSourceType, UseWindow, + UseMouseOptions, UseMouseReturn, UseMouseSourceType, UseWindow, }; use cfg_if::cfg_if; use default_struct_builder::DefaultBuilder; use leptos::*; +use std::convert::Infallible; use std::marker::PhantomData; /// Reactive mouse position related to an element. @@ -196,11 +197,11 @@ where } impl Default - for UseMouseInElementOptions + for UseMouseInElementOptions { fn default() -> Self { Self { - coord_type: UseMouseCoordType::::default(), + coord_type: UseMouseCoordType::::default(), target: use_window(), touch: true, reset_on_touch_ends: false,