diff options
Diffstat (limited to 'crates/ra_analysis/src/completion/completion_item.rs')
-rw-r--r-- | crates/ra_analysis/src/completion/completion_item.rs | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/crates/ra_analysis/src/completion/completion_item.rs b/crates/ra_analysis/src/completion/completion_item.rs index 445d6bf41..8aa9da005 100644 --- a/crates/ra_analysis/src/completion/completion_item.rs +++ b/crates/ra_analysis/src/completion/completion_item.rs | |||
@@ -53,8 +53,8 @@ pub(crate) struct Builder { | |||
53 | } | 53 | } |
54 | 54 | ||
55 | impl Builder { | 55 | impl Builder { |
56 | pub fn add_to(self, acc: &mut Vec<CompletionItem>) { | 56 | pub fn add_to(self, acc: &mut Completions) { |
57 | acc.push(self.build()) | 57 | acc.add(self.build()) |
58 | } | 58 | } |
59 | 59 | ||
60 | pub fn build(self) -> CompletionItem { | 60 | pub fn build(self) -> CompletionItem { |
@@ -81,7 +81,7 @@ impl Into<CompletionItem> for Builder { | |||
81 | } | 81 | } |
82 | 82 | ||
83 | /// Represents an in-progress set of completions being built. | 83 | /// Represents an in-progress set of completions being built. |
84 | #[derive(Debug)] | 84 | #[derive(Debug, Default)] |
85 | pub(crate) struct Completions { | 85 | pub(crate) struct Completions { |
86 | buf: Vec<CompletionItem>, | 86 | buf: Vec<CompletionItem>, |
87 | } | 87 | } |
@@ -90,6 +90,13 @@ impl Completions { | |||
90 | pub(crate) fn add(&mut self, item: impl Into<CompletionItem>) { | 90 | pub(crate) fn add(&mut self, item: impl Into<CompletionItem>) { |
91 | self.buf.push(item.into()) | 91 | self.buf.push(item.into()) |
92 | } | 92 | } |
93 | pub(crate) fn add_all<I>(&mut self, items: I) | ||
94 | where | ||
95 | I: IntoIterator, | ||
96 | I::Item: Into<CompletionItem>, | ||
97 | { | ||
98 | items.into_iter().for_each(|item| self.add(item.into())) | ||
99 | } | ||
93 | } | 100 | } |
94 | 101 | ||
95 | impl Into<Vec<CompletionItem>> for Completions { | 102 | impl Into<Vec<CompletionItem>> for Completions { |