From 08590cf6378e7130b0104b04ea877b4d07dacda5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9mie=20Drouet?= Date: Sun, 30 Jul 2023 13:40:32 +0000 Subject: [PATCH] refactor(mrml-core): format code MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Jérémie Drouet --- packages/mrml-core/src/mj_accordion/parse.rs | 4 +--- packages/mrml-core/src/mj_accordion_title/parse.rs | 6 ++---- packages/mrml-core/src/mj_attributes/parse.rs | 3 ++- packages/mrml-core/src/mj_attributes_all/parse.rs | 3 ++- packages/mrml-core/src/mj_attributes_class/parse.rs | 3 ++- packages/mrml-core/src/mj_attributes_element/parse.rs | 3 ++- packages/mrml-core/src/mj_body/parse.rs | 3 ++- packages/mrml-core/src/mj_breakpoint/parse.rs | 3 ++- packages/mrml-core/src/mj_button/parse.rs | 3 ++- packages/mrml-core/src/mj_carousel/parse.rs | 7 +++---- packages/mrml-core/src/mj_font/parse.rs | 3 ++- packages/mrml-core/src/mj_head/parse.rs | 3 ++- packages/mrml-core/src/mj_navbar/parse.rs | 4 +--- packages/mrml-core/src/mj_preview/parse.rs | 3 ++- packages/mrml-core/src/mj_social/parse.rs | 4 +--- packages/mrml-core/src/mj_social_element/parse.rs | 3 ++- packages/mrml-core/src/mj_style/parse.rs | 3 ++- packages/mrml-core/src/mj_title/parse.rs | 3 ++- packages/mrml-core/src/mjml/parse.rs | 3 +-- packages/mrml-core/src/node/parse.rs | 6 ++---- packages/mrml-core/src/prelude/parser/loader.rs | 4 ++-- packages/mrml-core/src/prelude/parser/mod.rs | 5 +++-- packages/mrml-core/src/prelude/parser/noop_loader.rs | 4 ++-- 23 files changed, 44 insertions(+), 42 deletions(-) diff --git a/packages/mrml-core/src/mj_accordion/parse.rs b/packages/mrml-core/src/mj_accordion/parse.rs index a4c12ca6..b1e7558c 100644 --- a/packages/mrml-core/src/mj_accordion/parse.rs +++ b/packages/mrml-core/src/mj_accordion/parse.rs @@ -3,9 +3,7 @@ use xmlparser::StrSpan; use super::{MjAccordion, MjAccordionChild}; use crate::comment::Comment; use crate::mj_accordion_element::NAME as MJ_ACCORDION_ELEMENT; -use crate::prelude::parser::{ - ChildrenParser, ElementParser, Error, MrmlParser, MrmlToken, -}; +use crate::prelude::parser::{ChildrenParser, ElementParser, Error, MrmlParser, MrmlToken}; impl<'a> ChildrenParser<'a, Vec> for MrmlParser<'a> { fn parse_children(&mut self) -> Result, Error> { diff --git a/packages/mrml-core/src/mj_accordion_title/parse.rs b/packages/mrml-core/src/mj_accordion_title/parse.rs index 21ed11b8..81415652 100644 --- a/packages/mrml-core/src/mj_accordion_title/parse.rs +++ b/packages/mrml-core/src/mj_accordion_title/parse.rs @@ -1,10 +1,8 @@ use xmlparser::StrSpan; use super::MjAccordionTitle; -use crate::{ - prelude::parser::{ChildrenParser, ElementParser, Error, MrmlParser}, - text::Text, -}; +use crate::prelude::parser::{ChildrenParser, ElementParser, Error, MrmlParser}; +use crate::text::Text; impl<'a> ChildrenParser<'a, Vec> for MrmlParser<'a> { fn parse_children(&mut self) -> Result, Error> { diff --git a/packages/mrml-core/src/mj_attributes/parse.rs b/packages/mrml-core/src/mj_attributes/parse.rs index de39ac43..61920b23 100644 --- a/packages/mrml-core/src/mj_attributes/parse.rs +++ b/packages/mrml-core/src/mj_attributes/parse.rs @@ -52,7 +52,8 @@ impl<'a> ElementParser<'a, MjAttributes> for MrmlParser<'a> { #[cfg(test)] mod tests { - use crate::{mj_attributes::MjAttributes, prelude::parser::MrmlParser}; + use crate::mj_attributes::MjAttributes; + use crate::prelude::parser::MrmlParser; #[test] fn parse_complete() { diff --git a/packages/mrml-core/src/mj_attributes_all/parse.rs b/packages/mrml-core/src/mj_attributes_all/parse.rs index 6cfa6889..8d270508 100644 --- a/packages/mrml-core/src/mj_attributes_all/parse.rs +++ b/packages/mrml-core/src/mj_attributes_all/parse.rs @@ -17,7 +17,8 @@ impl<'a> ElementParser<'a, MjAttributesAll> for MrmlParser<'a> { #[cfg(test)] mod tests { - use crate::{mj_attributes_all::MjAttributesAll, prelude::parser::MrmlParser}; + use crate::mj_attributes_all::MjAttributesAll; + use crate::prelude::parser::MrmlParser; #[test] fn parse_complete() { diff --git a/packages/mrml-core/src/mj_attributes_class/parse.rs b/packages/mrml-core/src/mj_attributes_class/parse.rs index 75fd0bed..9ec1592b 100644 --- a/packages/mrml-core/src/mj_attributes_class/parse.rs +++ b/packages/mrml-core/src/mj_attributes_class/parse.rs @@ -21,7 +21,8 @@ impl<'a> ElementParser<'a, MjAttributesClass> for MrmlParser<'a> { #[cfg(test)] mod tests { - use crate::{mj_attributes_class::MjAttributesClass, prelude::parser::MrmlParser}; + use crate::mj_attributes_class::MjAttributesClass; + use crate::prelude::parser::MrmlParser; #[test] fn parse_complete() { diff --git a/packages/mrml-core/src/mj_attributes_element/parse.rs b/packages/mrml-core/src/mj_attributes_element/parse.rs index d4e6548f..af19af6b 100644 --- a/packages/mrml-core/src/mj_attributes_element/parse.rs +++ b/packages/mrml-core/src/mj_attributes_element/parse.rs @@ -21,7 +21,8 @@ impl<'a> ElementParser<'a, MjAttributesElement> for MrmlParser<'a> { #[cfg(test)] mod tests { - use crate::{mj_attributes::MjAttributes, prelude::parser::MrmlParser}; + use crate::mj_attributes::MjAttributes; + use crate::prelude::parser::MrmlParser; #[test] fn parse_complete() { diff --git a/packages/mrml-core/src/mj_body/parse.rs b/packages/mrml-core/src/mj_body/parse.rs index 251480fa..d071aeb3 100644 --- a/packages/mrml-core/src/mj_body/parse.rs +++ b/packages/mrml-core/src/mj_body/parse.rs @@ -134,7 +134,8 @@ impl<'a> ElementParser<'a, MjBody> for MrmlParser<'a> { #[cfg(test)] mod tests { - use crate::{mj_body::MjBody, prelude::parser::MrmlParser}; + use crate::mj_body::MjBody; + use crate::prelude::parser::MrmlParser; #[test] fn parse_complete() { diff --git a/packages/mrml-core/src/mj_breakpoint/parse.rs b/packages/mrml-core/src/mj_breakpoint/parse.rs index c6c11c5d..b5125521 100644 --- a/packages/mrml-core/src/mj_breakpoint/parse.rs +++ b/packages/mrml-core/src/mj_breakpoint/parse.rs @@ -31,7 +31,8 @@ impl<'a> ElementParser<'a, MjBreakpoint> for MrmlParser<'a> { #[cfg(test)] mod tests { - use crate::{mj_breakpoint::MjBreakpoint, prelude::parser::MrmlParser}; + use crate::mj_breakpoint::MjBreakpoint; + use crate::prelude::parser::MrmlParser; #[test] fn success() { diff --git a/packages/mrml-core/src/mj_button/parse.rs b/packages/mrml-core/src/mj_button/parse.rs index 75424659..28273d7a 100644 --- a/packages/mrml-core/src/mj_button/parse.rs +++ b/packages/mrml-core/src/mj_button/parse.rs @@ -16,7 +16,8 @@ impl<'a> ElementParser<'a, MjButton> for MrmlParser<'a> { #[cfg(test)] mod tests { - use crate::{mj_button::MjButton, prelude::parser::MrmlParser}; + use crate::mj_button::MjButton; + use crate::prelude::parser::MrmlParser; #[test] fn success() { diff --git a/packages/mrml-core/src/mj_carousel/parse.rs b/packages/mrml-core/src/mj_carousel/parse.rs index 41ea4c06..5019beb5 100644 --- a/packages/mrml-core/src/mj_carousel/parse.rs +++ b/packages/mrml-core/src/mj_carousel/parse.rs @@ -3,9 +3,7 @@ use xmlparser::StrSpan; use super::{MjCarousel, MjCarouselChild}; use crate::comment::Comment; use crate::mj_carousel_image::NAME as MJ_CAROUSEL_IMAGE; -use crate::prelude::parser::{ - ChildrenParser, ElementParser, Error, MrmlParser, MrmlToken, -}; +use crate::prelude::parser::{ChildrenParser, ElementParser, Error, MrmlParser, MrmlToken}; impl<'a> ChildrenParser<'a, Vec> for MrmlParser<'a> { fn parse_children(&mut self) -> Result, Error> { @@ -46,7 +44,8 @@ impl<'a> ElementParser<'a, MjCarousel> for MrmlParser<'a> { #[cfg(test)] mod tests { - use crate::{mj_carousel::MjCarousel, prelude::parser::MrmlParser}; + use crate::mj_carousel::MjCarousel; + use crate::prelude::parser::MrmlParser; #[test] fn with_all_children() { diff --git a/packages/mrml-core/src/mj_font/parse.rs b/packages/mrml-core/src/mj_font/parse.rs index 41d62803..a6f64a37 100644 --- a/packages/mrml-core/src/mj_font/parse.rs +++ b/packages/mrml-core/src/mj_font/parse.rs @@ -33,7 +33,8 @@ impl<'a> ElementParser<'a, MjFont> for MrmlParser<'a> { #[cfg(test)] mod tests { - use crate::{mj_font::MjFont, prelude::parser::MrmlParser}; + use crate::mj_font::MjFont; + use crate::prelude::parser::MrmlParser; #[test] fn success() { diff --git a/packages/mrml-core/src/mj_head/parse.rs b/packages/mrml-core/src/mj_head/parse.rs index 61157c2a..4fc7690e 100644 --- a/packages/mrml-core/src/mj_head/parse.rs +++ b/packages/mrml-core/src/mj_head/parse.rs @@ -62,7 +62,8 @@ impl<'a> ElementParser<'a, MjHeadChild> for MrmlParser<'a> { #[cfg(test)] mod tests { - use crate::{mj_head::MjHead, prelude::parser::MrmlParser}; + use crate::mj_head::MjHead; + use crate::prelude::parser::MrmlParser; #[test] fn raw_children() { diff --git a/packages/mrml-core/src/mj_navbar/parse.rs b/packages/mrml-core/src/mj_navbar/parse.rs index 707d9ab1..99dbc37d 100644 --- a/packages/mrml-core/src/mj_navbar/parse.rs +++ b/packages/mrml-core/src/mj_navbar/parse.rs @@ -3,9 +3,7 @@ use xmlparser::StrSpan; use super::{MjNavbar, MjNavbarChild}; use crate::comment::Comment; use crate::mj_navbar_link::NAME as MJ_NAVBAR_LINK; -use crate::prelude::parser::{ - ChildrenParser, ElementParser, Error, MrmlParser, MrmlToken, -}; +use crate::prelude::parser::{ChildrenParser, ElementParser, Error, MrmlParser, MrmlToken}; impl<'a> ChildrenParser<'a, Vec> for MrmlParser<'a> { fn parse_children(&mut self) -> Result, Error> { diff --git a/packages/mrml-core/src/mj_preview/parse.rs b/packages/mrml-core/src/mj_preview/parse.rs index 83085e22..700a051d 100644 --- a/packages/mrml-core/src/mj_preview/parse.rs +++ b/packages/mrml-core/src/mj_preview/parse.rs @@ -22,7 +22,8 @@ impl<'a> ElementParser<'a, MjPreview> for MrmlParser<'a> { #[cfg(test)] mod tests { - use crate::{mj_preview::MjPreview, prelude::parser::MrmlParser}; + use crate::mj_preview::MjPreview; + use crate::prelude::parser::MrmlParser; #[test] fn should_parse() { diff --git a/packages/mrml-core/src/mj_social/parse.rs b/packages/mrml-core/src/mj_social/parse.rs index e50f80bf..17a2b7a4 100644 --- a/packages/mrml-core/src/mj_social/parse.rs +++ b/packages/mrml-core/src/mj_social/parse.rs @@ -3,9 +3,7 @@ use xmlparser::StrSpan; use super::{MjSocial, MjSocialChild}; use crate::comment::Comment; use crate::mj_social_element::NAME as MJ_SOCIAL_ELEMENT; -use crate::prelude::parser::{ - ChildrenParser, ElementParser, Error, MrmlParser, MrmlToken, -}; +use crate::prelude::parser::{ChildrenParser, ElementParser, Error, MrmlParser, MrmlToken}; impl<'a> ChildrenParser<'a, Vec> for MrmlParser<'a> { fn parse_children(&mut self) -> Result, Error> { diff --git a/packages/mrml-core/src/mj_social_element/parse.rs b/packages/mrml-core/src/mj_social_element/parse.rs index b6574fed..3eecf26b 100644 --- a/packages/mrml-core/src/mj_social_element/parse.rs +++ b/packages/mrml-core/src/mj_social_element/parse.rs @@ -16,7 +16,8 @@ impl<'a> ElementParser<'a, MjSocialElement> for MrmlParser<'a> { #[cfg(test)] mod tests { - use crate::{mj_social_element::MjSocialElement, prelude::parser::MrmlParser}; + use crate::mj_social_element::MjSocialElement; + use crate::prelude::parser::MrmlParser; #[test] fn parse_with_empty_children() { diff --git a/packages/mrml-core/src/mj_style/parse.rs b/packages/mrml-core/src/mj_style/parse.rs index 7000c0e5..5cb475e2 100644 --- a/packages/mrml-core/src/mj_style/parse.rs +++ b/packages/mrml-core/src/mj_style/parse.rs @@ -43,7 +43,8 @@ impl<'a> ElementParser<'a, MjStyle> for MrmlParser<'a> { #[cfg(test)] mod tests { - use crate::{mj_style::MjStyle, prelude::parser::MrmlParser}; + use crate::mj_style::MjStyle; + use crate::prelude::parser::MrmlParser; #[test] fn should_work_empty() { diff --git a/packages/mrml-core/src/mj_title/parse.rs b/packages/mrml-core/src/mj_title/parse.rs index f5df0e9e..b5ff7db3 100644 --- a/packages/mrml-core/src/mj_title/parse.rs +++ b/packages/mrml-core/src/mj_title/parse.rs @@ -22,7 +22,8 @@ impl<'a> ElementParser<'a, MjTitle> for MrmlParser<'a> { #[cfg(test)] mod tests { - use crate::{mj_title::MjTitle, prelude::parser::MrmlParser}; + use crate::mj_title::MjTitle; + use crate::prelude::parser::MrmlParser; #[test] fn success() { diff --git a/packages/mrml-core/src/mjml/parse.rs b/packages/mrml-core/src/mjml/parse.rs index a6ee34f3..35e90893 100644 --- a/packages/mrml-core/src/mjml/parse.rs +++ b/packages/mrml-core/src/mjml/parse.rs @@ -3,9 +3,8 @@ use xmlparser::StrSpan; use super::{Mjml, MjmlAttributes, MjmlChildren}; use crate::mj_body::NAME as MJ_BODY; use crate::mj_head::NAME as MJ_HEAD; -use crate::prelude::parser::Error; use crate::prelude::parser::{ - self, AttributesParser, ChildrenParser, ElementParser, MrmlParser, MrmlToken, + self, AttributesParser, ChildrenParser, ElementParser, Error, MrmlParser, MrmlToken, }; impl<'a> AttributesParser<'a, MjmlAttributes> for MrmlParser<'a> { diff --git a/packages/mrml-core/src/node/parse.rs b/packages/mrml-core/src/node/parse.rs index 149a718f..166b6091 100644 --- a/packages/mrml-core/src/node/parse.rs +++ b/packages/mrml-core/src/node/parse.rs @@ -40,10 +40,8 @@ // &mut self, // tag: xmlparser::StrSpan<'a>, // tokenizer: &mut xmlparser::Tokenizer<'a>, -// ) -> Result<(), Error> { -// self.children -// .push(T::parse(tag, tokenizer, self.opts.clone())?); -// Ok(()) +// ) -> Result<(), Error> { self.children .push(T::parse(tag, tokenizer, +// self.opts.clone())?); Ok(()) // } // parse_comment!(); diff --git a/packages/mrml-core/src/prelude/parser/loader.rs b/packages/mrml-core/src/prelude/parser/loader.rs index fe43adef..4ddc0a39 100644 --- a/packages/mrml-core/src/prelude/parser/loader.rs +++ b/packages/mrml-core/src/prelude/parser/loader.rs @@ -70,13 +70,13 @@ pub trait IncludeLoader: std::fmt::Debug { /// /// You can have an example of simple resolve function with the /// [`MemoryIncludeLoader`](crate::prelude::parser::memory_loader::MemoryIncludeLoader). - /// fn resolve(&self, path: &str) -> Result; } #[cfg(test)] mod tests { - use std::{io::ErrorKind, sync::Arc}; + use std::io::ErrorKind; + use std::sync::Arc; use super::IncludeLoaderError; diff --git a/packages/mrml-core/src/prelude/parser/mod.rs b/packages/mrml-core/src/prelude/parser/mod.rs index 19db02af..7ec7cc2c 100644 --- a/packages/mrml-core/src/prelude/parser/mod.rs +++ b/packages/mrml-core/src/prelude/parser/mod.rs @@ -1,9 +1,10 @@ -use std::{convert::TryFrom, fmt::Display, sync::Arc}; +use std::convert::TryFrom; +use std::fmt::Display; +use std::sync::Arc; use xmlparser::{StrSpan, Token, Tokenizer}; use self::loader::IncludeLoaderError; - use super::hash::Map; #[cfg(feature = "http-loader-base")] diff --git a/packages/mrml-core/src/prelude/parser/noop_loader.rs b/packages/mrml-core/src/prelude/parser/noop_loader.rs index 921feee1..7a81e552 100644 --- a/packages/mrml-core/src/prelude/parser/noop_loader.rs +++ b/packages/mrml-core/src/prelude/parser/noop_loader.rs @@ -5,8 +5,8 @@ use crate::prelude::parser::loader::IncludeLoader; #[derive(Debug, Default)] /// This struct is a simple -/// [`IncludeLoader`](crate::prelude::parser::loader::IncludeLoader) that doesn't -/// resolve any template. This is the default loader. +/// [`IncludeLoader`](crate::prelude::parser::loader::IncludeLoader) that +/// doesn't resolve any template. This is the default loader. /// /// # Example /// ```rust