clippy CI and all warnings fixed

This commit is contained in:
Maccesch 2023-06-10 19:43:51 +01:00
parent 4454f87f8e
commit 5e04455640
11 changed files with 25 additions and 28 deletions

View file

@ -23,17 +23,17 @@ jobs:
toolchain: nightly
profile: minimal
override: true
components: rustfmt
components: rustfmt, clippy
- name: Cache
uses: Swatinem/rust-cache@v2
- name: Check function count badge
run: python3 docs/generate_count_badge.py --check
- name: Check formatting
run: cargo fmt --check
# - name: Check if the README is up to date.
# run: |
# cargo install cargo-rdme
# cargo rdme --check
- name: Clippy check
uses: auguwu/clippy-action@1.1.2
with:
args: --all-features --tests -- -D warnings
- name: Run tests
run: cargo test --all-features

View file

@ -17,7 +17,7 @@ homepage = "https://leptos-use.rs"
leptos = "0.3.0"
wasm-bindgen = "0.2.86"
js-sys = "0.3.63"
default-struct-builder = "0.2.0"
default-struct-builder = "0.2.1"
num = { version = "0.4.0", optional = true }
serde = { version = "1.0.163", optional = true }
serde_json = { version = "1.0.96", optional = true }

View file

@ -1,3 +1,5 @@
<br/>
<p align="center">
<a href="https://github.com/synphonyte/leptos-use">
<img src="https://raw.githubusercontent.com/synphonyte/leptos-use/main/docs/logo.svg" alt="Leptos-Use Collection of essential Leptos utilities" width="150"/>

View file

@ -200,7 +200,7 @@ where
Ok(ref serialized) => match store.get_item(&k) {
Ok(old_value) => {
if old_value.as_ref() != Some(serialized) {
if let Err(e) = store.set_item(&k, &serialized) {
if let Err(e) = store.set_item(&k, serialized) {
on_err(UseStorageError::StorageAccessError(e));
} else {
let mut event_init = web_sys::CustomEventInit::new();

View file

@ -149,7 +149,7 @@ where
};
let cleanup_prev_el = Rc::clone(&cleanup_prev_element);
let closure = closure_js.clone();
let closure = closure_js;
create_effect(cx, move |_| {
cleanup_prev_el.borrow()();

View file

@ -38,7 +38,7 @@ pub fn use_media_query(cx: Scope, query: impl Into<MaybeSignal<String>>) -> Sign
let (matches, set_matches) = create_signal(cx, false);
let media_query: Rc<RefCell<Option<web_sys::MediaQueryList>>> = Rc::new(RefCell::new(None));
let remove_listener: Rc<RefCell<Option<Box<dyn Fn()>>>> = Rc::new(RefCell::new(None));
let remove_listener: RemoveListener = Rc::new(RefCell::new(None));
let rem_listener = Rc::clone(&remove_listener);
@ -88,3 +88,5 @@ pub fn use_media_query(cx: Scope, query: impl Into<MaybeSignal<String>>) -> Sign
matches.into()
}
type RemoveListener = Rc<RefCell<Option<Box<dyn Fn()>>>>;

View file

@ -174,7 +174,7 @@ where
cx,
target.clone(),
touchmove,
touch_handler.clone(),
touch_handler,
event_listener_options.clone(),
);
if options.reset_on_touch_ends {

View file

@ -150,10 +150,10 @@ impl Default for UseResizeObserverOptions {
}
}
impl Into<web_sys::ResizeObserverOptions> for UseResizeObserverOptions {
fn into(self) -> web_sys::ResizeObserverOptions {
impl From<UseResizeObserverOptions> for web_sys::ResizeObserverOptions {
fn from(val: UseResizeObserverOptions) -> Self {
let mut options = web_sys::ResizeObserverOptions::new();
options.box_(self.box_);
options.box_(val.box_);
options
}
}

View file

@ -210,8 +210,7 @@ where
let scroll = scroll_to.clone();
let set_x = Box::new(move |x| scroll(Some(x), None));
let scroll = scroll_to.clone();
let set_y = Box::new(move |y| scroll(None, Some(y)));
let set_y = Box::new(move |y| scroll_to(None, Some(y)));
let (is_scrolling, set_is_scrolling) = create_signal(cx, false);
@ -475,9 +474,9 @@ pub enum ScrollBehavior {
Smooth,
}
impl Into<web_sys::ScrollBehavior> for ScrollBehavior {
fn into(self) -> web_sys::ScrollBehavior {
match self {
impl From<ScrollBehavior> for web_sys::ScrollBehavior {
fn from(val: ScrollBehavior) -> Self {
match val {
ScrollBehavior::Auto => web_sys::ScrollBehavior::Auto,
ScrollBehavior::Smooth => web_sys::ScrollBehavior::Smooth,
}

View file

@ -62,12 +62,8 @@ impl FilterOptions {
R: 'static,
{
match self {
FilterOptions::Debounce { ms, options } => {
Box::new(debounce_filter(ms.clone(), *options))
}
FilterOptions::Throttle { ms, options } => {
Box::new(throttle_filter(ms.clone(), *options))
}
FilterOptions::Debounce { ms, options } => Box::new(debounce_filter(*ms, *options)),
FilterOptions::Throttle { ms, options } => Box::new(throttle_filter(*ms, *options)),
FilterOptions::None => Box::new(|invoke: Box<dyn CloneableFnWithReturn<R>>| {
Rc::new(RefCell::new(Some(invoke())))
}),

View file

@ -160,14 +160,14 @@ where
create_effect(cx, move |did_run_before| {
if !is_active() {
return ();
return;
}
let deps_value = deps();
if !options.immediate && did_run_before.is_none() {
prev_deps_value.replace(Some(deps_value));
return ();
return;
}
cur_deps_value.replace(Some(deps_value.clone()));
@ -181,8 +181,6 @@ where
prev_callback_value.replace(callback_value);
prev_deps_value.replace(Some(deps_value));
()
});
move || {