aboutsummaryrefslogtreecommitdiff
path: root/mingling_core/src
diff options
context:
space:
mode:
Diffstat (limited to 'mingling_core/src')
-rw-r--r--mingling_core/src/comp/suggest.rs36
1 files changed, 36 insertions, 0 deletions
diff --git a/mingling_core/src/comp/suggest.rs b/mingling_core/src/comp/suggest.rs
index 88fa5fc..dda5026 100644
--- a/mingling_core/src/comp/suggest.rs
+++ b/mingling_core/src/comp/suggest.rs
@@ -56,6 +56,42 @@ impl Suggest {
(suggest, _) => suggest,
}
}
+
+ /// Adds multiple simple suggestions (without descriptions) to the `Suggest` set.
+ ///
+ /// Each item produced by the iterator is wrapped in a [`SuggestItem::Simple`]
+ /// variant and inserted into the underlying `BTreeSet`.
+ ///
+ /// # Arguments
+ ///
+ /// * `items` — A collection of suggestion strings to add.
+ pub fn add_suggest(&mut self, items: impl Into<Vec<String>>) {
+ for item in items.into() {
+ self.insert(SuggestItem::Simple(item));
+ }
+ }
+
+ /// Adds multiple suggestions with a shared description to the `Suggest` set.
+ ///
+ /// Each item produced by the iterator is wrapped in a
+ /// [`SuggestItem::WithDescription`] variant using the provided description,
+ /// and inserted into the underlying `BTreeSet`.
+ ///
+ /// # Arguments
+ ///
+ /// * `items` — A collection of suggestion strings to add.
+ /// * `desc` — The description to attach to each suggestion. Must implement
+ /// `Into<String>`.
+ pub fn add_suggest_with_description(
+ &mut self,
+ items: impl Into<Vec<String>>,
+ desc: impl Into<String>,
+ ) {
+ let desc_str = desc.into();
+ for item in items.into() {
+ self.insert(SuggestItem::WithDescription(item, desc_str.clone()));
+ }
+ }
}
impl<T> From<T> for Suggest