Make the set_description API a bit nicer.

This commit is contained in:
Lucy 2022-03-01 15:32:52 -05:00
parent feee2bacc3
commit f7f87104f6
No known key found for this signature in database
GPG key ID: EBC517FAD666BBF1
2 changed files with 6 additions and 3 deletions

View file

@ -47,12 +47,14 @@ impl LabeledItem {
.send(LabeledItemMessage::Title(title.to_string()));
}
pub fn set_description<S>(&self, title: Option<S>)
pub fn set_description<S, O>(&self, description: O)
where
S: ToString,
O: Into<Option<S>>,
{
let description = description.into();
self._sender
.send(LabeledItemMessage::Desc(title.map(|s| s.to_string())));
.send(LabeledItemMessage::Desc(description.map(|s| s.to_string())));
}
pub fn set_alignment(&self, align: Align) {

View file

@ -45,9 +45,10 @@ impl LabeledItem {
self.inner().model.set_title(title)
}
pub fn set_description<S>(&self, description: Option<S>)
pub fn set_description<S, O>(&self, description: O)
where
S: ToString,
O: Into<Option<S>>,
{
self.inner().model.set_description(description)
}