Accept an Option<&str> as a link name
continuous-integration/drone/pr Build encountered an error Details

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<String>, 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<String>`s, which might make users lives a little easier
This commit is contained in:
Emii Tatsuo 2020-11-30 02:01:15 -05:00
parent c743056263
commit 23df792abf
No known key found for this signature in database
GPG Key ID: 68FAB2E2E6DFC98B
1 changed files with 6 additions and 2 deletions

View File

@ -18,10 +18,14 @@ impl Builder {
self self
} }
pub fn link<T: Into<String>>(mut self, to: T, name: Option<String>) -> Builder { pub fn link<T, S>(mut self, to: T, name: Option<S>) -> Self
where
T: Into<String>,
S: Into<String>,
{
self.nodes.push(Node::Link { self.nodes.push(Node::Link {
to: to.into(), to: to.into(),
name: name, name: name.map(Into::into),
}); });
self self
} }