From fde1432b5930c58a5391afb4fd2bf423ff4e9053 Mon Sep 17 00:00:00 2001 From: rambip Date: Thu, 28 Sep 2023 23:29:55 +0200 Subject: [PATCH] forgot formatting, AGAIN --- leptos_reactive/src/callback.rs | 23 +++++++++++++++-------- leptos_reactive/tests/callback.rs | 7 ------- 2 files changed, 15 insertions(+), 15 deletions(-) delete mode 100644 leptos_reactive/tests/callback.rs diff --git a/leptos_reactive/src/callback.rs b/leptos_reactive/src/callback.rs index 22a7595203..8271d36db4 100644 --- a/leptos_reactive/src/callback.rs +++ b/leptos_reactive/src/callback.rs @@ -41,7 +41,7 @@ //! Use `SyncCallback` when you want the function to be `Sync` and `Send`. //! Otherwise, use it exactly the same way as `Callback` -use crate::{StoredValue, store_value}; +use crate::{store_value, StoredValue}; use std::{fmt, sync::Arc}; /// A wrapper trait for calling callbacks. @@ -75,7 +75,9 @@ pub trait Callable { /// } /// ``` -pub struct Callback(StoredValue Out>>); +pub struct Callback( + StoredValue Out>>, +); impl fmt::Debug for Callback { fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> Result<(), fmt::Error> { @@ -154,10 +156,11 @@ impl Fn<(In,)> for Callback { } } - /// A callback type that is `Send` and `Sync` if its input type is `Send` and `Sync`. /// You can use exactly the way you use `Callback` -pub struct SyncCallback(StoredValue Out>>); +pub struct SyncCallback( + StoredValue Out>>, +); impl fmt::Debug for SyncCallback { fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> Result<(), fmt::Error> { @@ -261,8 +264,10 @@ mod tests { #[test] fn callback_from_html() { - use leptos::html::{AnyElement, HtmlElement}; - use leptos::*; + use leptos::{ + html::{AnyElement, HtmlElement}, + *, + }; let _callback: Callback> = (|x: String| { @@ -280,8 +285,10 @@ mod tests { #[test] fn sync_callback_from_html() { - use leptos::html::{AnyElement, HtmlElement}; - use leptos::*; + use leptos::{ + html::{AnyElement, HtmlElement}, + *, + }; let _callback: SyncCallback> = (|x: String| { diff --git a/leptos_reactive/tests/callback.rs b/leptos_reactive/tests/callback.rs deleted file mode 100644 index 349900d744..0000000000 --- a/leptos_reactive/tests/callback.rs +++ /dev/null @@ -1,7 +0,0 @@ -use leptos_reactive::{Callable, Callback, SyncCallback}; - -#[test] -fn call_test(){ - let callback = Callback::new(|x: i32| x*2); - assert!(callback.call(4)==8); -}