From 23df792abfa45620cc4f4c3f3ebc3136940be667 Mon Sep 17 00:00:00 2001 From: Emii Tatsuo Date: Mon, 30 Nov 2020 02:01:15 -0500 Subject: [PATCH] Accept an Option<&str> as a link name Many users may be adding links to their documents with &'static str's as the name, which means that they would manually have to convert to an Option, leading to code that looks like `link("gemini://emii.gay", Some(String::from("My Website")))` instead of the simpler `link("gemini://emii.gay/", Some("My Website"))`. We can change this method to accept the latter in addition to accepting `Option`s, which might make users lives a little easier --- gemtext/src/lib.rs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/gemtext/src/lib.rs b/gemtext/src/lib.rs index e350b95..8bf3cfa 100644 --- a/gemtext/src/lib.rs +++ b/gemtext/src/lib.rs @@ -18,10 +18,14 @@ impl Builder { self } - pub fn link>(mut self, to: T, name: Option) -> Builder { + pub fn link(mut self, to: T, name: Option) -> Self + where + T: Into, + S: Into, + { self.nodes.push(Node::Link { to: to.into(), - name: name, + name: name.map(Into::into), }); self }