From 056918d7730b13b00017b497cf99a10e3002f8fa Mon Sep 17 00:00:00 2001 From: Jovansonlee Cesar Date: Thu, 18 Apr 2024 05:46:09 +0800 Subject: [PATCH] cargo fmt --- crates/html-parser/src/lib.rs | 30 ++++++++++++------------- examples/experimentals/src/app.rs | 2 +- examples/experimentals/src/button.rs | 8 +------ examples/experimentals/src/date_time.rs | 7 +----- 4 files changed, 17 insertions(+), 30 deletions(-) diff --git a/crates/html-parser/src/lib.rs b/crates/html-parser/src/lib.rs index 4336f0f9..2272928c 100644 --- a/crates/html-parser/src/lib.rs +++ b/crates/html-parser/src/lib.rs @@ -85,23 +85,21 @@ fn process_node(node: &rphtml::parser::Node) -> Result>, P .attrs .iter() .filter_map(|attr| { - attr.key - .as_ref() - .and_then(|key| { - let key = String::from_iter(key.content.iter()); - if let Some(attr_key) = lookup::match_attribute(&key) { - let value = if let Some(value) = &attr.value { - let value = String::from_iter(value.content.iter()); - AttributeValue::Simple(Value::from(value)) - } else { - AttributeValue::Empty - }; - Some(Attribute::new(None, attr_key, value)) + attr.key.as_ref().and_then(|key| { + let key = String::from_iter(key.content.iter()); + if let Some(attr_key) = lookup::match_attribute(&key) { + let value = if let Some(value) = &attr.value { + let value = String::from_iter(value.content.iter()); + AttributeValue::Simple(Value::from(value)) } else { - log::warn!("Not a standard html attribute: {}", key); - None - } - }) + AttributeValue::Empty + }; + Some(Attribute::new(None, attr_key, value)) + } else { + log::warn!("Not a standard html attribute: {}", key); + None + } + }) }) .collect(); diff --git a/examples/experimentals/src/app.rs b/examples/experimentals/src/app.rs index 06327aff..6a599e98 100644 --- a/examples/experimentals/src/app.rs +++ b/examples/experimentals/src/app.rs @@ -1,6 +1,6 @@ //#![deny(warnings)] use crate::button::{self, Button}; -use crate::date_time::{self, DateTimeWidget, date, time}; +use crate::date_time::{self, date, time, DateTimeWidget}; use js_sys::Date; use sauron::dom::component; use sauron::dom::stateful_component; diff --git a/examples/experimentals/src/button.rs b/examples/experimentals/src/button.rs index 57bfcb0f..024aa762 100644 --- a/examples/experimentals/src/button.rs +++ b/examples/experimentals/src/button.rs @@ -48,13 +48,7 @@ impl Component for Button { } impl StatefulComponent for Button { - fn attribute_changed( - &mut self, - attr_name: &str, - new_value: Vec, - ) - { - } + fn attribute_changed(&mut self, attr_name: &str, new_value: Vec) {} /// append a child into this component fn append_children(&mut self, children: Vec) { diff --git a/examples/experimentals/src/date_time.rs b/examples/experimentals/src/date_time.rs index e76fbae4..21c7717e 100644 --- a/examples/experimentals/src/date_time.rs +++ b/examples/experimentals/src/date_time.rs @@ -182,12 +182,7 @@ where impl StatefulComponent for DateTimeWidget<()> { /// this is called when the attributes in the mount is changed - fn attribute_changed( - &mut self, - attr_name: &str, - new_value: Vec, - ) - { + fn attribute_changed(&mut self, attr_name: &str, new_value: Vec) { match &*attr_name { "time" => { if let Some(new_value) = new_value[0].as_string() {