Accept an Option<&str> as a link name
continuous-integration/drone/pr Build encountered an error
Details
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:
parent
c743056263
commit
23df792abf
|
@ -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
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue