From 96e6a8b809f8b4dda5744affcf27cfad8b8e1921 Mon Sep 17 00:00:00 2001 From: Jovansonlee Cesar Date: Thu, 4 Apr 2024 14:45:46 +0800 Subject: [PATCH] cargo fmt --- crates/core/src/dom.rs | 4 +- crates/core/src/dom/application.rs | 5 +- crates/core/src/dom/cmd.rs | 53 +++++++++---------- .../src/dom/component/stateful_component.rs | 4 +- crates/core/src/dom/component/template.rs | 5 +- .../core/src/dom/component/web_component.rs | 4 +- crates/core/src/dom/dispatch.rs | 15 ++---- crates/core/src/dom/document.rs | 5 +- crates/core/src/dom/dom_node.rs | 12 ++--- crates/core/src/dom/effects.rs | 40 +++----------- crates/core/src/dom/program.rs | 2 +- crates/core/src/dom/program/app_context.rs | 2 +- crates/core/src/dom/time.rs | 1 - crates/core/src/dom/window.rs | 12 ++--- examples/counter/src/lib.rs | 3 +- .../data-viewer/src/views/resize_wrapper.rs | 8 +-- examples/delay/src/lib.rs | 11 ++-- examples/experimentals/src/button.rs | 1 - examples/experimentals/src/date_time.rs | 5 +- examples/fetch-data-macro-syntax/src/lib.rs | 24 ++++----- examples/fetch-data/src/lib.rs | 24 ++++----- examples/fragments/src/lib.rs | 6 +-- examples/interactive/src/app.rs | 2 +- examples/now-you-see-me/src/lib.rs | 14 ++--- examples/svg-clock-macro-syntax/src/lib.rs | 2 +- examples/svg-clock/src/lib.rs | 2 +- tests/dom_safe_html.rs | 2 +- 27 files changed, 107 insertions(+), 161 deletions(-) diff --git a/crates/core/src/dom.rs b/crates/core/src/dom.rs index 2bf93c76..10be950f 100644 --- a/crates/core/src/dom.rs +++ b/crates/core/src/dom.rs @@ -1,13 +1,13 @@ //! This module provides functionalities for //! manipulating the actual Document Object Model in the browser +pub use cmd::Cmd; pub use component::Component; pub use effects::Effects; -pub use cmd::Cmd; +mod cmd; mod component; mod effects; -mod cmd; use cfg_if::cfg_if; diff --git a/crates/core/src/dom/application.rs b/crates/core/src/dom/application.rs index fb6d1b41..2b1510a7 100644 --- a/crates/core/src/dom/application.rs +++ b/crates/core/src/dom/application.rs @@ -1,6 +1,6 @@ +use crate::dom::Cmd; use crate::vdom::Node; pub use skip_diff::{skip_if, SkipDiff, SkipPath}; -use crate::dom::Cmd; /// pub mod skip_diff; @@ -40,8 +40,7 @@ pub trait Application: Sized + 'static { /// This is for diagnostic and performance measurement purposes. /// /// Warning: DO NOT use for anything else other than the intended purpose - fn measurements(&mut self, _measurements: Measurements){ - } + fn measurements(&mut self, _measurements: Measurements) {} } /// Contains the time it took for the last app update call for the component diff --git a/crates/core/src/dom/cmd.rs b/crates/core/src/dom/cmd.rs index eebb34b0..533f8719 100644 --- a/crates/core/src/dom/cmd.rs +++ b/crates/core/src/dom/cmd.rs @@ -1,14 +1,14 @@ +use crate::dom::Effects; use futures::channel::mpsc; use futures::channel::mpsc::UnboundedReceiver; use futures::StreamExt; use std::future::Future; use std::pin::Pin; -use crate::dom::Effects; #[cfg(feature = "with-dom")] use wasm_bindgen::closure::Closure; /// Cnd is a way to tell the Runtime that something needs to be executed -pub struct Cmd{ +pub struct Cmd { /// commands pub(crate) commands: Vec>, } @@ -22,7 +22,6 @@ pub enum Command { Sub(Sub), } - impl Cmd where MSG: 'static, @@ -40,13 +39,16 @@ where where F: Future + 'static, { - Self{ + Self { commands: vec![Command::single(f)], } } /// Creates a Cmd which will be polled multiple times - pub fn recurring(rx: UnboundedReceiver, event_closure: Closure) -> Self { - Self{ + pub fn recurring( + rx: UnboundedReceiver, + event_closure: Closure, + ) -> Self { + Self { commands: vec![Command::sub(rx, event_closure)], } } @@ -57,48 +59,44 @@ where F: Fn(MSG) -> MSG2 + 'static + Clone, MSG2: 'static, { - Cmd{ - commands: self.commands.into_iter().map(|t|t.map_msg(f.clone())).collect(), + Cmd { + commands: self + .commands + .into_iter() + .map(|t| t.map_msg(f.clone())) + .collect(), } } /// batch together multiple Cmd into one task pub fn batch(tasks: impl IntoIterator) -> Self { let mut commands = vec![]; - for task in tasks.into_iter(){ + for task in tasks.into_iter() { commands.extend(task.commands); } - Self {commands, - } + Self { commands } } /// pub fn none() -> Self { - Self{commands: vec![], - } + Self { commands: vec![] } } - - } - impl From> for Cmd - where MSG: 'static +where + MSG: 'static, { /// Convert Effects that has only follow ups fn from(effects: Effects) -> Self { // we can safely ignore the effects here // as there is no content on it. - let Effects { - local, - external:_, - } = effects; + let Effects { local, external: _ } = effects; Cmd::batch(local.into_iter().map(Cmd::from)) } } - impl Command where MSG: 'static, @@ -111,10 +109,13 @@ where Self::Action(Action::new(f)) } - /// + /// #[cfg(feature = "with-dom")] - pub fn sub(rx: UnboundedReceiver, event_closure: Closure) -> Self { - Self::Sub(Sub{ + pub fn sub( + rx: UnboundedReceiver, + event_closure: Closure, + ) -> Self { + Self::Sub(Sub { receiver: rx, event_closure, }) @@ -141,7 +142,6 @@ where Self::Sub(task) => task.next().await, } } - } /// Action is used to do asynchronous operations @@ -168,7 +168,6 @@ where } } - /// apply a function to the msg to create a different task which has a different msg fn map_msg(self, f: F) -> Action where diff --git a/crates/core/src/dom/component/stateful_component.rs b/crates/core/src/dom/component/stateful_component.rs index 1408558c..73417778 100644 --- a/crates/core/src/dom/component/stateful_component.rs +++ b/crates/core/src/dom/component/stateful_component.rs @@ -145,9 +145,7 @@ pub fn stateful_component( children: impl IntoIterator>, ) -> Node where - COMP: Component - + StatefulComponent - + Application + 'static, + COMP: Component + StatefulComponent + Application + 'static, MSG: Default + 'static, MSG2: 'static, { diff --git a/crates/core/src/dom/component/template.rs b/crates/core/src/dom/component/template.rs index 87eb719c..1d7e827a 100644 --- a/crates/core/src/dom/component/template.rs +++ b/crates/core/src/dom/component/template.rs @@ -171,7 +171,10 @@ fn create_fragment_node_no_listeners( dom_node } -fn create_leaf_node_no_listeners(parent_node: Rc>, leaf: &Leaf) -> DomNode { +fn create_leaf_node_no_listeners( + parent_node: Rc>, + leaf: &Leaf, +) -> DomNode { match leaf { Leaf::Text(txt) => DomNode { inner: DomInner::Text(document().create_text_node(txt)), diff --git a/crates/core/src/dom/component/web_component.rs b/crates/core/src/dom/component/web_component.rs index c2b1024c..5e81ae2d 100644 --- a/crates/core/src/dom/component/web_component.rs +++ b/crates/core/src/dom/component/web_component.rs @@ -176,9 +176,7 @@ where .app .borrow_mut() .connected_callback(); - self.program - .update_dom() - .expect("must update dom"); + self.program.update_dom().expect("must update dom"); } /// called when the web component is removed diff --git a/crates/core/src/dom/dispatch.rs b/crates/core/src/dom/dispatch.rs index 1447750b..bb564884 100644 --- a/crates/core/src/dom/dispatch.rs +++ b/crates/core/src/dom/dispatch.rs @@ -2,7 +2,7 @@ //! when the application starts or after the application updates. //! use crate::dom::Program; -use crate::dom::{Application, Effects, Cmd}; +use crate::dom::{Application, Cmd, Effects}; use wasm_bindgen_futures::spawn_local; /// Dispatch is a command to be executed by the system. @@ -58,9 +58,7 @@ where /// Tell the runtime that there are no commands. pub fn none() -> Self { - Dispatch { - commands: vec![], - } + Dispatch { commands: vec![] } } /// returns true if commands is empty @@ -68,7 +66,6 @@ where self.commands.is_empty() } - /// Executes the Dispatch pub(crate) fn emit(self, program: Program) { for cb in self.commands { @@ -96,16 +93,12 @@ where fn from(effects: Effects) -> Self { // we can safely ignore the effects here // as there is no content on it. - let Effects { - local, - external: _, - } = effects; + let Effects { local, external: _ } = effects; Dispatch::batch(local.into_iter().map(Dispatch::from)) } } - impl From for Dispatch where APP: Application, @@ -122,7 +115,7 @@ where { fn from(task: Cmd) -> Self { Dispatch::new(move |program| { - for mut command in task.commands.into_iter(){ + for mut command in task.commands.into_iter() { let program = program.downgrade(); spawn_local(async move { let mut program = program.upgrade().expect("upgrade"); diff --git a/crates/core/src/dom/document.rs b/crates/core/src/dom/document.rs index e7f0c754..4236aa2d 100644 --- a/crates/core/src/dom/document.rs +++ b/crates/core/src/dom/document.rs @@ -1,14 +1,13 @@ -use crate::dom::{dom_node::intern,Cmd}; +use crate::dom::document; +use crate::dom::{dom_node::intern, Cmd}; use futures::channel::mpsc; use wasm_bindgen::{prelude::*, JsCast}; -use crate::dom::document; /// Provides function for document related functions #[derive(Clone, Copy)] pub struct Document; impl Document { - /// pub fn on_selectionchange(mut cb: F) -> Cmd where diff --git a/crates/core/src/dom/dom_node.rs b/crates/core/src/dom/dom_node.rs index 9a0a3852..9a7934a3 100644 --- a/crates/core/src/dom/dom_node.rs +++ b/crates/core/src/dom/dom_node.rs @@ -426,8 +426,7 @@ impl DomNode { parent.replace_child(self, replacement); } else { //NOTE: This must be replacing a mount node - self - .as_element() + self.as_element() .replace_with_with_node_1(&replacement.as_node()) .expect("must replace child"); } @@ -517,9 +516,11 @@ impl DomNode { Ok(()) } - fn dispatch_mount_event(&self){ - let event_target:web_sys::EventTarget = self.as_element().unchecked_into(); - event_target.dispatch_event(&MountEvent::create_web_event()).expect("must be ok"); + fn dispatch_mount_event(&self) { + let event_target: web_sys::EventTarget = self.as_element().unchecked_into(); + event_target + .dispatch_event(&MountEvent::create_web_event()) + .expect("must be ok"); } /// render this DomNode into an html string represenation @@ -768,7 +769,6 @@ where self.create_dom_node(parent_node, &real_comp_view) } - /// set element with the dom attrs pub(crate) fn set_element_dom_attrs( &self, diff --git a/crates/core/src/dom/effects.rs b/crates/core/src/dom/effects.rs index f1713aa4..6c19ccc2 100644 --- a/crates/core/src/dom/effects.rs +++ b/crates/core/src/dom/effects.rs @@ -30,14 +30,10 @@ where { Self { local: local.into_iter().map(|l| Cmd::once(ready(l))).collect(), - external: external - .into_iter() - .map(|x| Cmd::once(ready(x))) - .collect(), + external: external.into_iter().map(|x| Cmd::once(ready(x))).collect(), } } - /// Create an Effects with local messages that will be executed on the next update loop on this Component pub fn with_local(local: impl IntoIterator) -> Self { Self { @@ -46,7 +42,6 @@ where } } - /// Create an Effects with extern messages that will be executed on the parent Component pub fn with_external(external: impl IntoIterator) -> Self where @@ -54,14 +49,10 @@ where { Self { local: vec![], - external: external - .into_iter() - .map(|x| Cmd::once(ready(x))) - .collect(), + external: external.into_iter().map(|x| Cmd::once(ready(x))).collect(), } } - /// Create and empty Effects pub fn none() -> Self { Self { @@ -79,10 +70,7 @@ where F: Fn(MSG) -> MSG2 + Clone + 'static, MSG2: 'static, { - let Effects { - local, - external, - } = self; + let Effects { local, external } = self; Effects { local: local.into_iter().map(|l| l.map_msg(f.clone())).collect(), external, @@ -97,10 +85,7 @@ where XMSG: 'static, XMSG2: 'static, { - let Effects { - local, - external, - } = self; + let Effects { local, external } = self; Effects { local, external: external.into_iter().map(|l| l.map_msg(f.clone())).collect(), @@ -117,10 +102,7 @@ where XMSG: 'static, XMSG2: 'static, { - let Effects { - local, - external, - } = self; + let Effects { local, external } = self; Effects { local: external @@ -138,8 +120,6 @@ where self } - - /// Merge all the internal objects of this Vec of Effects to produce only one. pub fn batch(all_effects: impl IntoIterator) -> Self { let mut local = vec![]; @@ -148,10 +128,7 @@ where local.extend(effect.local); external.extend(effect.external); } - Effects { - local, - external, - } + Effects { local, external } } /// Extern the local and external MSG of this Effect @@ -186,10 +163,7 @@ where { /// merge external msg into local msg, if they are of the same type pub fn merge(self) -> Effects { - let Effects { - local, - external, - } = self; + let Effects { local, external } = self; Effects { local: local.into_iter().chain(external.into_iter()).collect(), diff --git a/crates/core/src/dom/program.rs b/crates/core/src/dom/program.rs index 5b1cd760..5a348ea1 100644 --- a/crates/core/src/dom/program.rs +++ b/crates/core/src/dom/program.rs @@ -487,7 +487,7 @@ where weak_count, }; - #[cfg(all(feature = "with-debug",feature = "use-template"))] + #[cfg(all(feature = "with-debug", feature = "use-template"))] { let total = crate::dom::component::template::total_time_spent(); log::info!("total: {:#?}", total); diff --git a/crates/core/src/dom/program/app_context.rs b/crates/core/src/dom/program/app_context.rs index b8889056..e27063b0 100644 --- a/crates/core/src/dom/program/app_context.rs +++ b/crates/core/src/dom/program/app_context.rs @@ -136,7 +136,7 @@ where } #[cfg(feature = "with-measure")] - pub fn measurements(&mut self, measurements: Measurements) { + pub fn measurements(&mut self, measurements: Measurements) { self.app.borrow_mut().measurements(measurements) } diff --git a/crates/core/src/dom/time.rs b/crates/core/src/dom/time.rs index b76d83ab..2b07daf0 100644 --- a/crates/core/src/dom/time.rs +++ b/crates/core/src/dom/time.rs @@ -7,7 +7,6 @@ use wasm_bindgen::{prelude::*, JsCast}; pub struct Time; impl Time { - /// do this task at every `ms` interval pub fn every(interval_ms: i32, cb: F) -> Cmd where diff --git a/crates/core/src/dom/window.rs b/crates/core/src/dom/window.rs index 1b87aa7c..ef7e344c 100644 --- a/crates/core/src/dom/window.rs +++ b/crates/core/src/dom/window.rs @@ -130,15 +130,13 @@ impl Window { let (mut tx, rx) = mpsc::unbounded(); let closure_cb: Closure = Closure::new(move |event: web_sys::Event| { - let key_event: web_sys::KeyboardEvent = event.dyn_into().expect("must be key event"); + let key_event: web_sys::KeyboardEvent = + event.dyn_into().expect("must be key event"); let msg = cb(key_event); tx.start_send(msg).expect("send"); }); window() - .add_event_listener_with_callback( - intern("keyup"), - closure_cb.as_ref().unchecked_ref(), - ) + .add_event_listener_with_callback(intern("keyup"), closure_cb.as_ref().unchecked_ref()) .expect("add event callback"); Cmd::recurring(rx, closure_cb) } @@ -152,7 +150,8 @@ impl Window { let (mut tx, rx) = mpsc::unbounded(); let closure_cb: Closure = Closure::new(move |event: web_sys::Event| { - let key_event: web_sys::KeyboardEvent = event.dyn_into().expect("must be key event"); + let key_event: web_sys::KeyboardEvent = + event.dyn_into().expect("must be key event"); let msg = cb(key_event); tx.start_send(msg).expect("send"); }); @@ -165,7 +164,6 @@ impl Window { Cmd::recurring(rx, closure_cb) } - /// scroll the window to the top of the document pub fn scroll_to_top(msg: MSG) -> Cmd where diff --git a/examples/counter/src/lib.rs b/examples/counter/src/lib.rs index d2b55d90..51aabd3a 100644 --- a/examples/counter/src/lib.rs +++ b/examples/counter/src/lib.rs @@ -1,6 +1,5 @@ use sauron::{ - html::text, html::units::px, jss, node, wasm_bindgen, Application, Node, Program, - Cmd, + html::text, html::units::px, jss, node, wasm_bindgen, Application, Cmd, Node, Program, }; enum Msg { diff --git a/examples/data-viewer/src/views/resize_wrapper.rs b/examples/data-viewer/src/views/resize_wrapper.rs index 43bb546d..abe63caa 100644 --- a/examples/data-viewer/src/views/resize_wrapper.rs +++ b/examples/data-viewer/src/views/resize_wrapper.rs @@ -55,12 +55,8 @@ impl Application for ResizeWrapper { /// not being triggered fn init(&mut self) -> Cmd { Cmd::batch([ - Window::on_mouseup(|event| { - Msg::EndResize(event.client_x(), event.client_y()) - }), - Window::on_mousemove(|event| { - Msg::MouseMove(event.client_x(), event.client_y()) - }), + Window::on_mouseup(|event| Msg::EndResize(event.client_x(), event.client_y())), + Window::on_mousemove(|event| Msg::MouseMove(event.client_x(), event.client_y())), Cmd::from(self.data_view.init().map_msg(Msg::DataViewMsg)), ]) } diff --git a/examples/delay/src/lib.rs b/examples/delay/src/lib.rs index 998c239a..091e1c41 100644 --- a/examples/delay/src/lib.rs +++ b/examples/delay/src/lib.rs @@ -1,5 +1,6 @@ #![deny(warnings)] #![deny(clippy::all)] +use futures::channel::mpsc; use log::trace; use sauron::{ dom::{delay, TimeoutCallbackHandle}, @@ -13,7 +14,6 @@ use std::rc::Rc; use std::sync::atomic::AtomicBool; use std::sync::atomic::Ordering; use wasm_bindgen_futures::spawn_local; -use futures::channel::mpsc; pub enum Msg { Click, @@ -95,9 +95,12 @@ impl Application for App { .expect("must have a handle"); *current_handle.borrow_mut() = Some(handle); - Cmd::recurring(rx, sauron::Closure::new(|_:sauron::web_sys::Event|{ - panic!("This is not called!"); - })) + Cmd::recurring( + rx, + sauron::Closure::new(|_: sauron::web_sys::Event| { + panic!("This is not called!"); + }), + ) } Msg::NoOp => Cmd::none(), } diff --git a/examples/experimentals/src/button.rs b/examples/experimentals/src/button.rs index 3d39fef5..ed2bdee3 100644 --- a/examples/experimentals/src/button.rs +++ b/examples/experimentals/src/button.rs @@ -47,7 +47,6 @@ impl Component for Button { } } - impl StatefulComponent for Button { fn attribute_changed( &mut self, diff --git a/examples/experimentals/src/date_time.rs b/examples/experimentals/src/date_time.rs index f4ec5bc5..8da7edf0 100644 --- a/examples/experimentals/src/date_time.rs +++ b/examples/experimentals/src/date_time.rs @@ -180,7 +180,6 @@ where } } - impl StatefulComponent for DateTimeWidget<()> { /// this is called when the attributes in the mount is changed fn attribute_changed( @@ -272,9 +271,7 @@ impl DateTimeCustomElement { as Application>::style(&self.program.app()).join(""); self.program.inject_style_to_mount(&dynamic_style); - self.program - .update_dom() - .expect("must update dom"); + self.program.update_dom().expect("must update dom"); } #[wasm_bindgen(method, js_name = disconnectedCallback)] diff --git a/examples/fetch-data-macro-syntax/src/lib.rs b/examples/fetch-data-macro-syntax/src/lib.rs index 1cdf6d75..400ed349 100644 --- a/examples/fetch-data-macro-syntax/src/lib.rs +++ b/examples/fetch-data-macro-syntax/src/lib.rs @@ -51,18 +51,16 @@ impl App { fn fetch_page(&self) -> Cmd { let url = format!("{}?page={}&per_page={}", DATA_URL, self.page, PER_PAGE); - Cmd::new( - async move { - let msg = match Http::fetch_text(&url).await { - Ok(v) => match serde_json::from_str(&v) { - Ok(data1) => Msg::ReceivedData(data1), - Err(err) => Msg::JsonError(err), - }, - Err(e) => Msg::RequestError(e), - }; - msg - } - ) + Cmd::new(async move { + let msg = match Http::fetch_text(&url).await { + Ok(v) => match serde_json::from_str(&v) { + Ok(data1) => Msg::ReceivedData(data1), + Err(err) => Msg::JsonError(err), + }, + Err(e) => Msg::RequestError(e), + }; + msg + }) } } @@ -75,7 +73,7 @@ impl Application for App { } fn view(&self) -> Node { - log::info!("disabled: {}", {self.page <= 1}); + log::info!("disabled: {}", { self.page <= 1 }); node! {
diff --git a/examples/fetch-data/src/lib.rs b/examples/fetch-data/src/lib.rs index 0ad14634..cfe2079c 100644 --- a/examples/fetch-data/src/lib.rs +++ b/examples/fetch-data/src/lib.rs @@ -4,7 +4,7 @@ use sauron::html::attributes::*; use sauron::html::events::*; use sauron::html::*; use sauron::js_sys::TypeError; -use sauron::{jss, text, wasm_bindgen, Application, Node, Program, Cmd}; +use sauron::{jss, text, wasm_bindgen, Application, Cmd, Node, Program}; use serde::Deserialize; #[macro_use] @@ -57,18 +57,16 @@ impl App { fn fetch_page(&self) -> Cmd { let url = format!("{}?page={}&per_page={}", DATA_URL, self.page, PER_PAGE); - Cmd::new( - async move { - let msg = match Http::fetch_text(&url).await { - Ok(v) => match serde_json::from_str(&v) { - Ok(data1) => Msg::ReceivedData(data1), - Err(err) => Msg::JsonError(err), - }, - Err(e) => Msg::RequestError(e), - }; - msg - } - ) + Cmd::new(async move { + let msg = match Http::fetch_text(&url).await { + Ok(v) => match serde_json::from_str(&v) { + Ok(data1) => Msg::ReceivedData(data1), + Err(err) => Msg::JsonError(err), + }, + Err(e) => Msg::RequestError(e), + }; + msg + }) } } diff --git a/examples/fragments/src/lib.rs b/examples/fragments/src/lib.rs index 2efd97b0..b32b86ed 100644 --- a/examples/fragments/src/lib.rs +++ b/examples/fragments/src/lib.rs @@ -1,7 +1,7 @@ +use crate::html::node_list; +use futures::channel::mpsc; use sauron::dom::{delay, spawn_local}; use sauron::{html::fragment, *}; -use futures::channel::mpsc; -use crate::html::node_list; #[wasm_bindgen(start)] pub fn start() { @@ -23,7 +23,7 @@ impl Application for App { type MSG = Msg; fn init(&mut self) -> Cmd { - Time::every(1000, ||Msg::AddItem) + Time::every(1000, || Msg::AddItem) } fn update(&mut self, msg: Msg) -> Cmd diff --git a/examples/interactive/src/app.rs b/examples/interactive/src/app.rs index 4f8fad0f..88ea2e19 100644 --- a/examples/interactive/src/app.rs +++ b/examples/interactive/src/app.rs @@ -1,7 +1,7 @@ #![deny(warnings)] +use futures::channel::mpsc; use js_sys::Date; use sauron::{html::attributes::*, html::events::*, html::*, jss, web_sys::MouseEvent, *}; -use futures::channel::mpsc; pub enum Msg { Click, diff --git a/examples/now-you-see-me/src/lib.rs b/examples/now-you-see-me/src/lib.rs index f6de7817..ce31612b 100644 --- a/examples/now-you-see-me/src/lib.rs +++ b/examples/now-you-see-me/src/lib.rs @@ -21,9 +21,7 @@ impl Application for App { type MSG = Msg; fn init(&mut self) -> Cmd { - Cmd::new( async move{ - Msg::ToggleShow - }) + Cmd::new(async move { Msg::ToggleShow }) } fn update(&mut self, msg: Msg) -> Cmd { match msg { @@ -34,12 +32,10 @@ impl Application for App { } else { document().set_title("Now, you don't!"); } - Cmd::new( - async move { - delay(2000).await; - Msg::ToggleShow - } - ) + Cmd::new(async move { + delay(2000).await; + Msg::ToggleShow + }) } } } diff --git a/examples/svg-clock-macro-syntax/src/lib.rs b/examples/svg-clock-macro-syntax/src/lib.rs index 374900f7..9c495013 100644 --- a/examples/svg-clock-macro-syntax/src/lib.rs +++ b/examples/svg-clock-macro-syntax/src/lib.rs @@ -32,7 +32,7 @@ impl Application for Clock { // we wire the window set_interval api to trigger an Msg::Tick // by dispatching it from the program, through the Cmd interface fn init(&mut self) -> Cmd { - Time::every(1_000/60, ||Msg::Tick) + Time::every(1_000 / 60, || Msg::Tick) } fn update(&mut self, msg: Msg) -> Cmd { diff --git a/examples/svg-clock/src/lib.rs b/examples/svg-clock/src/lib.rs index d95cd343..acc3c683 100644 --- a/examples/svg-clock/src/lib.rs +++ b/examples/svg-clock/src/lib.rs @@ -29,7 +29,7 @@ impl Application for Clock { // we wire the window set_interval api to trigger an Msg::Tick // by dispatching it from the program, through the Cmd interface fn init(&mut self) -> Cmd { - Time::every(17, ||Msg::Tick) + Time::every(17, || Msg::Tick) } fn update(&mut self, msg: Msg) -> Cmd { diff --git a/tests/dom_safe_html.rs b/tests/dom_safe_html.rs index 7b071f1a..533be136 100644 --- a/tests/dom_safe_html.rs +++ b/tests/dom_safe_html.rs @@ -2,9 +2,9 @@ use sauron::dom::DomNode; use sauron::parse_html; use sauron::*; +use std::rc::Rc; use test_fixtures::simple_program; use wasm_bindgen_test::*; -use std::rc::Rc; mod test_fixtures;