aboutsummaryrefslogtreecommitdiff
path: root/mingling_core/src/comp/suggest.rs
diff options
context:
space:
mode:
Diffstat (limited to 'mingling_core/src/comp/suggest.rs')
-rw-r--r--mingling_core/src/comp/suggest.rs13
1 files changed, 8 insertions, 5 deletions
diff --git a/mingling_core/src/comp/suggest.rs b/mingling_core/src/comp/suggest.rs
index 4a26c38..2cbd391 100644
--- a/mingling_core/src/comp/suggest.rs
+++ b/mingling_core/src/comp/suggest.rs
@@ -321,13 +321,10 @@ impl Suggest {
impl<T> From<T> for Suggest
where
T: IntoIterator,
- T::Item: Into<String>,
+ T::Item: Into<SuggestItem>,
{
fn from(items: T) -> Self {
- let suggests = items
- .into_iter()
- .map(|item| SuggestItem::new(item.into()))
- .collect();
+ let suggests = items.into_iter().map(Into::into).collect();
Self::Suggest(suggests)
}
}
@@ -701,6 +698,12 @@ impl From<String> for SuggestItem {
}
}
+impl From<&str> for SuggestItem {
+ fn from(suggest: &str) -> Self {
+ Self::new(suggest.to_string())
+ }
+}
+
impl From<(String, String)> for SuggestItem {
fn from((suggest, description): (String, String)) -> Self {
Self::new_with_desc(suggest, description)