diff options
Diffstat (limited to 'src/convert')
| -rw-r--r-- | src/convert/html.rs | 6 | ||||
| -rw-r--r-- | src/convert/markdown.rs | 8 |
2 files changed, 7 insertions, 7 deletions
diff --git a/src/convert/html.rs b/src/convert/html.rs index 2f031b0..7b1cafe 100644 --- a/src/convert/html.rs +++ b/src/convert/html.rs @@ -18,7 +18,7 @@ use crate::ast::Node; -pub fn convert(source: Vec<Node>) -> String { +pub fn convert(source: &[Node]) -> String { let mut html = String::new(); // Since we have an AST tree of the Gemtext, it is very easy to convert from @@ -33,7 +33,7 @@ pub fn convert(source: Vec<Node>) -> String { html.push_str(&format!( "<a href=\"{}\">{}</a><br>", to, - text.unwrap_or_else(|| to.clone()) + text.clone().unwrap_or_else(|| to.clone()) )); } Node::Heading { @@ -55,7 +55,7 @@ pub fn convert(source: Vec<Node>) -> String { html.push_str(&format!( "<ul>{}</ul>", items - .into_iter() + .iter() .map(|i| format!("<li>{}</li>", i)) .collect::<Vec<String>>() .join("\n") diff --git a/src/convert/markdown.rs b/src/convert/markdown.rs index b400002..c368973 100644 --- a/src/convert/markdown.rs +++ b/src/convert/markdown.rs @@ -18,7 +18,7 @@ use crate::ast::Node; -pub fn convert(source: Vec<Node>) -> String { +pub fn convert(source: &[Node]) -> String { let mut markdown = String::new(); // Since we have an AST tree of the Gemtext, it is very easy to convert from @@ -30,7 +30,7 @@ pub fn convert(source: Vec<Node>) -> String { to, text, } => - markdown.push_str(&*text.map_or_else( + markdown.push_str(&*text.clone().map_or_else( || format!("<{}>\n", to), |text| format!("[{}]({})\n", text, to), )), @@ -53,7 +53,7 @@ pub fn convert(source: Vec<Node>) -> String { markdown.push_str(&format!( "{}\n", items - .into_iter() + .iter() .map(|i| format!("- {}", i)) .collect::<Vec<String>>() .join("\n"), @@ -65,7 +65,7 @@ pub fn convert(source: Vec<Node>) -> String { } => { markdown.push_str(&format!( "```{}\n{}```\n", - alt_text.unwrap_or_else(|| "".to_string()), + alt_text.clone().unwrap_or_else(|| "".to_string()), text )); } |