diff --git a/src/nodes/accordion.rs b/src/nodes/accordion.rs index 09d760e..72dba38 100644 --- a/src/nodes/accordion.rs +++ b/src/nodes/accordion.rs @@ -11,7 +11,7 @@ use crate::toolkit::{ use super::accordion_tab::AccordionTab; -#[derive(Debug, PartialEq, Serialize)] +#[derive(Debug, PartialEq, Serialize, Clone)] #[serde(tag = "type")] pub enum AccordionNodes { AccordionTab(AccordionTab), @@ -39,7 +39,7 @@ impl From for AccordionNodes { } } -#[derive(Debug, PartialEq, Serialize)] +#[derive(Debug, PartialEq, Serialize, Clone)] pub struct Accordion { #[serde(skip_serializing)] consumed_all_input: bool, diff --git a/src/nodes/accordion_tab.rs b/src/nodes/accordion_tab.rs index 9701920..3cc3800 100644 --- a/src/nodes/accordion_tab.rs +++ b/src/nodes/accordion_tab.rs @@ -15,7 +15,7 @@ use super::{ list::List, paragraph::Paragraph, }; -#[derive(Debug, PartialEq, Serialize)] +#[derive(Debug, PartialEq, Serialize, Clone)] #[serde(tag = "type")] pub enum AccordionTabNodes { Pargaraph(Paragraph), @@ -124,7 +124,7 @@ impl From for AccordionTabNodes { } } -#[derive(Debug, PartialEq, Serialize)] +#[derive(Debug, PartialEq, Serialize, Clone)] pub struct AccordionTab { pub header: Option, pub nodes: Vec, diff --git a/src/nodes/anchor.rs b/src/nodes/anchor.rs index 94b1c84..29fc3f2 100644 --- a/src/nodes/anchor.rs +++ b/src/nodes/anchor.rs @@ -9,7 +9,7 @@ use crate::{ }; /// Representation of an anchor -#[derive(Debug, PartialEq, Serialize)] +#[derive(Debug, PartialEq, Serialize, Clone)] pub struct Anchor { pub text: String, pub url: String, diff --git a/src/nodes/bold.rs b/src/nodes/bold.rs index f3f33f1..446e09c 100644 --- a/src/nodes/bold.rs +++ b/src/nodes/bold.rs @@ -14,7 +14,7 @@ use crate::{ }, }; -#[derive(Debug, PartialEq, Serialize)] +#[derive(Debug, PartialEq, Serialize, Clone)] #[serde(tag = "type")] pub enum BoldNodes { Text(Text), @@ -60,7 +60,7 @@ impl Node for BoldNodes { } } -#[derive(Debug, PartialEq, Serialize)] +#[derive(Debug, PartialEq, Serialize, Clone, Default)] pub struct Bold { pub nodes: Vec, } @@ -92,12 +92,6 @@ impl Branch for Bold { } } -impl Default for Bold { - fn default() -> Self { - Self::new() - } -} - impl Display for Bold { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { write!( diff --git a/src/nodes/code.rs b/src/nodes/code.rs index a207b1c..ef9125a 100644 --- a/src/nodes/code.rs +++ b/src/nodes/code.rs @@ -4,7 +4,7 @@ use serde::Serialize; use crate::toolkit::{context::Context, deserializer::Deserializer, matcher::Matcher, node::Node}; -#[derive(Debug, PartialEq, Serialize)] +#[derive(Debug, PartialEq, Serialize, Clone)] pub struct Code { pub lang: String, pub code: String, diff --git a/src/nodes/divider.rs b/src/nodes/divider.rs index a458948..074d8fe 100644 --- a/src/nodes/divider.rs +++ b/src/nodes/divider.rs @@ -4,7 +4,7 @@ use serde::Serialize; use crate::toolkit::{context::Context, deserializer::Deserializer, matcher::Matcher, node::Node}; -#[derive(Debug, PartialEq, Serialize)] +#[derive(Debug, PartialEq, Serialize, Clone)] pub struct Divider { #[serde(skip_serializing)] consumed_all_input: bool, diff --git a/src/nodes/embed.rs b/src/nodes/embed.rs index 96449eb..0171787 100644 --- a/src/nodes/embed.rs +++ b/src/nodes/embed.rs @@ -4,7 +4,7 @@ use serde::Serialize; use crate::toolkit::{deserializer::Deserializer, matcher::Matcher, node::Node}; -#[derive(Debug, PartialEq, Serialize)] +#[derive(Debug, PartialEq, Serialize, Clone)] pub struct Embed { pub url: String, pub kind: String, diff --git a/src/nodes/heading.rs b/src/nodes/heading.rs index d00ee62..dd39194 100644 --- a/src/nodes/heading.rs +++ b/src/nodes/heading.rs @@ -4,7 +4,7 @@ use serde::Serialize; use crate::toolkit::{context::Context, deserializer::Deserializer, matcher::Matcher, node::Node}; -#[derive(Debug, PartialEq, Serialize)] +#[derive(Debug, PartialEq, Serialize, Clone)] pub struct Heading { pub level: u8, pub text: String, diff --git a/src/nodes/highlight.rs b/src/nodes/highlight.rs index d432f97..5bb8f25 100644 --- a/src/nodes/highlight.rs +++ b/src/nodes/highlight.rs @@ -11,7 +11,7 @@ use crate::toolkit::{ use super::paragraph::Paragraph; -#[derive(Debug, PartialEq, Serialize)] +#[derive(Debug, PartialEq, Serialize, Clone)] #[serde(tag = "type")] pub enum HighlightNodes { Paragraph(Paragraph), @@ -39,7 +39,7 @@ impl From for HighlightNodes { } } -#[derive(Debug, PartialEq, Serialize)] +#[derive(Debug, PartialEq, Serialize, Clone)] pub struct Highlight { pub header: Option, pub icon: Option, diff --git a/src/nodes/image.rs b/src/nodes/image.rs index 2b0bd7d..0bcdd00 100644 --- a/src/nodes/image.rs +++ b/src/nodes/image.rs @@ -4,7 +4,7 @@ use serde::Serialize; use crate::toolkit::{context::Context, deserializer::Deserializer, matcher::Matcher, node::Node}; -#[derive(Debug, PartialEq, Serialize)] +#[derive(Debug, PartialEq, Serialize, Clone)] pub struct Image { pub alt: String, pub src: String, diff --git a/src/nodes/image_gallery.rs b/src/nodes/image_gallery.rs index adfad36..74e3f1c 100644 --- a/src/nodes/image_gallery.rs +++ b/src/nodes/image_gallery.rs @@ -11,7 +11,7 @@ use crate::toolkit::{ use super::image::Image; -#[derive(Debug, PartialEq, Serialize)] +#[derive(Debug, PartialEq, Serialize, Clone)] #[serde(tag = "type")] pub enum ImageGalleryNodes { Image(Image), @@ -41,7 +41,7 @@ impl From for ImageGalleryNodes { /// Image Gallery node is a node that contains multiple Image nodes /// it starts with `!!!\n` and ends with `\n!!!` -#[derive(Debug, PartialEq, Serialize)] +#[derive(Debug, PartialEq, Serialize, Clone)] pub struct ImageGallery { pub nodes: Vec, #[serde(skip_serializing)] diff --git a/src/nodes/inline_code.rs b/src/nodes/inline_code.rs index 105ec61..2c8a0a8 100644 --- a/src/nodes/inline_code.rs +++ b/src/nodes/inline_code.rs @@ -4,7 +4,7 @@ use serde::Serialize; use crate::toolkit::{context::Context, deserializer::Deserializer, matcher::Matcher, node::Node}; -#[derive(Debug, PartialEq, Serialize)] +#[derive(Debug, PartialEq, Serialize, Clone)] pub struct InlineCode { pub text: String, } diff --git a/src/nodes/italic.rs b/src/nodes/italic.rs index 24c53eb..8ec0232 100644 --- a/src/nodes/italic.rs +++ b/src/nodes/italic.rs @@ -8,7 +8,7 @@ use crate::{ }; /// Representation of an Italic text -#[derive(Debug, PartialEq, Serialize)] +#[derive(Debug, PartialEq, Serialize, Clone)] pub struct Italic { pub text: String, } diff --git a/src/nodes/list.rs b/src/nodes/list.rs index 19415a8..794e726 100644 --- a/src/nodes/list.rs +++ b/src/nodes/list.rs @@ -17,7 +17,7 @@ pub enum ListTypes { Ordered, } -#[derive(Debug, PartialEq, Serialize)] +#[derive(Debug, PartialEq, Serialize, Clone)] #[serde(tag = "type")] pub enum ListNodes { ListItem(ListItem), @@ -45,7 +45,7 @@ impl From for ListNodes { } } -#[derive(Debug, PartialEq, Serialize)] +#[derive(Debug, PartialEq, Serialize, Clone)] pub struct List { pub list_type: ListTypes, pub level: usize, diff --git a/src/nodes/list_item.rs b/src/nodes/list_item.rs index dc37cd9..78ec360 100644 --- a/src/nodes/list_item.rs +++ b/src/nodes/list_item.rs @@ -9,7 +9,7 @@ use super::{ list_item_content::ListItemContent, }; -#[derive(Debug, PartialEq, Serialize)] +#[derive(Debug, PartialEq, Serialize, Clone)] pub struct ListItem { pub list_type: ListTypes, pub level: usize, diff --git a/src/nodes/list_item_content.rs b/src/nodes/list_item_content.rs index 10b1106..11d98a6 100644 --- a/src/nodes/list_item_content.rs +++ b/src/nodes/list_item_content.rs @@ -14,7 +14,7 @@ use super::{ strikethrough::Strikethrough, text::Text, }; -#[derive(Debug, PartialEq, Serialize)] +#[derive(Debug, PartialEq, Serialize, Clone)] #[serde(tag = "type")] pub enum ListItemContentNodes { A(Anchor), @@ -87,7 +87,7 @@ impl Node for ListItemContentNodes { } } -#[derive(Debug, PartialEq, Serialize)] +#[derive(Debug, PartialEq, Serialize, Clone)] pub struct ListItemContent { #[serde(skip_serializing)] consumed_all_input: bool, diff --git a/src/nodes/metadata.rs b/src/nodes/metadata.rs index 6b92785..f68b89a 100644 --- a/src/nodes/metadata.rs +++ b/src/nodes/metadata.rs @@ -4,7 +4,7 @@ use crate::toolkit::{context::Context, deserializer::Deserializer, matcher::Matc use chrono::{DateTime, FixedOffset}; use serde::Serialize; -#[derive(Debug, PartialEq, Serialize, Default)] +#[derive(Debug, PartialEq, Serialize, Default, Clone)] pub struct Metadata { pub header: Option, pub timestamp: Option>, diff --git a/src/nodes/paragraph.rs b/src/nodes/paragraph.rs index 49601cf..679349a 100644 --- a/src/nodes/paragraph.rs +++ b/src/nodes/paragraph.rs @@ -13,7 +13,7 @@ use crate::toolkit::{ matcher::Matcher, }; -#[derive(Debug, PartialEq, Serialize)] +#[derive(Debug, PartialEq, Serialize, Clone)] #[serde(tag = "type")] pub enum ParagraphNodes { A(Anchor), @@ -86,7 +86,7 @@ impl Node for ParagraphNodes { } } -#[derive(Debug, PartialEq, Serialize)] +#[derive(Debug, PartialEq, Serialize, Clone)] pub struct Paragraph { #[serde(skip_serializing)] consumed_all_input: bool, diff --git a/src/nodes/strikethrough.rs b/src/nodes/strikethrough.rs index d675a4b..826fcbe 100644 --- a/src/nodes/strikethrough.rs +++ b/src/nodes/strikethrough.rs @@ -8,7 +8,7 @@ use crate::{ }; /// Representation of strike through -#[derive(Debug, PartialEq, Serialize)] +#[derive(Debug, PartialEq, Serialize, Clone)] pub struct Strikethrough { pub text: String, } diff --git a/src/nodes/text.rs b/src/nodes/text.rs index 12794c2..76ce99f 100644 --- a/src/nodes/text.rs +++ b/src/nodes/text.rs @@ -9,7 +9,7 @@ use crate::toolkit::{ }; /// Representation of a regular text -#[derive(Debug, PartialEq, Serialize)] +#[derive(Debug, PartialEq, Serialize, Clone)] pub struct Text { pub text: String, } diff --git a/src/nodes/yamd.rs b/src/nodes/yamd.rs index 121ed3d..6af54b6 100644 --- a/src/nodes/yamd.rs +++ b/src/nodes/yamd.rs @@ -15,7 +15,7 @@ use super::{ image_gallery::ImageGallery, list::List, metadata::Metadata, }; -#[derive(Debug, PartialEq, Serialize)] +#[derive(Debug, PartialEq, Serialize, Clone)] #[serde(tag = "type")] pub enum YamdNodes { P(Paragraph), @@ -134,7 +134,7 @@ impl Node for YamdNodes { } /// Yamd is a parent node for every node. -#[derive(Debug, PartialEq, Serialize)] +#[derive(Debug, PartialEq, Serialize, Clone, Default)] pub struct Yamd { pub metadata: Metadata, pub nodes: Vec, @@ -190,12 +190,6 @@ impl Deserializer for Yamd { } } -impl Default for Yamd { - fn default() -> Self { - Self::new(None) - } -} - impl Display for Yamd { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { write!( diff --git a/src/toolkit/context.rs b/src/toolkit/context.rs index 3b70b5a..0725fa0 100644 --- a/src/toolkit/context.rs +++ b/src/toolkit/context.rs @@ -20,7 +20,7 @@ impl From for ContextValues { } } -#[derive(Clone, Debug)] +#[derive(Clone, Debug, Default)] pub struct Context { inner: HashMap, } @@ -51,12 +51,6 @@ impl Context { } } -impl Default for Context { - fn default() -> Self { - Self::new() - } -} - #[cfg(test)] mod tests { use super::Context;