Skip to content

Commit

Permalink
derive clone
Browse files Browse the repository at this point in the history
  • Loading branch information
Lurk committed Oct 21, 2023
1 parent 1a6356f commit 95585f7
Show file tree
Hide file tree
Showing 22 changed files with 31 additions and 49 deletions.
4 changes: 2 additions & 2 deletions src/nodes/accordion.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down Expand Up @@ -39,7 +39,7 @@ impl From<AccordionTab> for AccordionNodes {
}
}

#[derive(Debug, PartialEq, Serialize)]
#[derive(Debug, PartialEq, Serialize, Clone)]
pub struct Accordion {
#[serde(skip_serializing)]
consumed_all_input: bool,
Expand Down
4 changes: 2 additions & 2 deletions src/nodes/accordion_tab.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down Expand Up @@ -124,7 +124,7 @@ impl From<Code> for AccordionTabNodes {
}
}

#[derive(Debug, PartialEq, Serialize)]
#[derive(Debug, PartialEq, Serialize, Clone)]
pub struct AccordionTab {
pub header: Option<String>,
pub nodes: Vec<AccordionTabNodes>,
Expand Down
2 changes: 1 addition & 1 deletion src/nodes/anchor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
10 changes: 2 additions & 8 deletions src/nodes/bold.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ use crate::{
},
};

#[derive(Debug, PartialEq, Serialize)]
#[derive(Debug, PartialEq, Serialize, Clone)]
#[serde(tag = "type")]
pub enum BoldNodes {
Text(Text),
Expand Down Expand Up @@ -60,7 +60,7 @@ impl Node for BoldNodes {
}
}

#[derive(Debug, PartialEq, Serialize)]
#[derive(Debug, PartialEq, Serialize, Clone, Default)]
pub struct Bold {
pub nodes: Vec<BoldNodes>,
}
Expand Down Expand Up @@ -92,12 +92,6 @@ impl Branch<BoldNodes> 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!(
Expand Down
2 changes: 1 addition & 1 deletion src/nodes/code.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion src/nodes/divider.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion src/nodes/embed.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion src/nodes/heading.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
4 changes: 2 additions & 2 deletions src/nodes/highlight.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down Expand Up @@ -39,7 +39,7 @@ impl From<Paragraph> for HighlightNodes {
}
}

#[derive(Debug, PartialEq, Serialize)]
#[derive(Debug, PartialEq, Serialize, Clone)]
pub struct Highlight {
pub header: Option<String>,
pub icon: Option<String>,
Expand Down
2 changes: 1 addition & 1 deletion src/nodes/image.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
4 changes: 2 additions & 2 deletions src/nodes/image_gallery.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down Expand Up @@ -41,7 +41,7 @@ impl From<Image> 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<ImageGalleryNodes>,
#[serde(skip_serializing)]
Expand Down
2 changes: 1 addition & 1 deletion src/nodes/inline_code.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}
Expand Down
2 changes: 1 addition & 1 deletion src/nodes/italic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}
Expand Down
4 changes: 2 additions & 2 deletions src/nodes/list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down Expand Up @@ -45,7 +45,7 @@ impl From<ListItem> for ListNodes {
}
}

#[derive(Debug, PartialEq, Serialize)]
#[derive(Debug, PartialEq, Serialize, Clone)]
pub struct List {
pub list_type: ListTypes,
pub level: usize,
Expand Down
2 changes: 1 addition & 1 deletion src/nodes/list_item.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
4 changes: 2 additions & 2 deletions src/nodes/list_item_content.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion src/nodes/metadata.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<String>,
pub timestamp: Option<DateTime<FixedOffset>>,
Expand Down
4 changes: 2 additions & 2 deletions src/nodes/paragraph.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion src/nodes/strikethrough.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}
Expand Down
2 changes: 1 addition & 1 deletion src/nodes/text.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}
Expand Down
10 changes: 2 additions & 8 deletions src/nodes/yamd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down Expand Up @@ -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<YamdNodes>,
Expand Down Expand Up @@ -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!(
Expand Down
8 changes: 1 addition & 7 deletions src/toolkit/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ impl From<char> for ContextValues {
}
}

#[derive(Clone, Debug)]
#[derive(Clone, Debug, Default)]
pub struct Context {
inner: HashMap<String, ContextValues>,
}
Expand Down Expand Up @@ -51,12 +51,6 @@ impl Context {
}
}

impl Default for Context {
fn default() -> Self {
Self::new()
}
}

#[cfg(test)]
mod tests {
use super::Context;
Expand Down

0 comments on commit 95585f7

Please sign in to comment.