diff options
| author | Fuwn <[email protected]> | 2022-05-18 01:52:36 +0000 |
|---|---|---|
| committer | Fuwn <[email protected]> | 2022-05-18 01:52:36 +0000 |
| commit | 11405ce0600d61f3772a7efe7fbd3de4cc2bf892 (patch) | |
| tree | 24ebda9cc59ae51b4e87fdde688fe009eaf420af /src/convert | |
| parent | chore(makefile): use --all-features (diff) | |
| download | germ-11405ce0600d61f3772a7efe7fbd3de4cc2bf892.tar.xz germ-11405ce0600d61f3772a7efe7fbd3de4cc2bf892.zip | |
fix: global clippy lint fixes
Diffstat (limited to 'src/convert')
| -rw-r--r-- | src/convert/html.rs | 4 | ||||
| -rw-r--r-- | src/convert/markdown.rs | 11 |
2 files changed, 7 insertions, 8 deletions
diff --git a/src/convert/html.rs b/src/convert/html.rs index 18aec1e..2f031b0 100644 --- a/src/convert/html.rs +++ b/src/convert/html.rs @@ -33,7 +33,7 @@ pub fn convert(source: Vec<Node>) -> String { html.push_str(&format!( "<a href=\"{}\">{}</a><br>", to, - text.unwrap_or(to.clone()) + text.unwrap_or_else(|| to.clone()) )); } Node::Heading { @@ -67,7 +67,7 @@ pub fn convert(source: Vec<Node>) -> String { } => { html.push_str(&format!("<pre>{}</pre>", text)); } - _ => {} + Node::Whitespace => {} } } diff --git a/src/convert/markdown.rs b/src/convert/markdown.rs index b07d5f1..ccd2304 100644 --- a/src/convert/markdown.rs +++ b/src/convert/markdown.rs @@ -30,11 +30,10 @@ pub fn convert(source: Vec<Node>) -> String { to, text, } => - markdown.push_str(&if let Some(text) = text { - format!("[{}]({})", text, to) - } else { - format!("<{}>", to) - }), + markdown.push_str(&*text.map_or_else( + || format!("<{}>", to), + |text| format!("[{}]({})", text, to), + )), Node::Heading { level, text, @@ -65,7 +64,7 @@ pub fn convert(source: Vec<Node>) -> String { } => { markdown.push_str(&format!( "```{}\n{}```", - alt_text.unwrap_or("".to_string()), + alt_text.unwrap_or_else(|| "".to_string()), text )); } |