};
fn snippet(ctx: &CompletionContext, cap: SnippetCap, label: &str, snippet: &str) -> Builder {
- CompletionItem::new(CompletionKind::Snippet, ctx.source_range(), label)
- .insert_snippet(cap, snippet)
- .kind(CompletionItemKind::Snippet)
+ let mut builder = CompletionItem::new(CompletionKind::Snippet, ctx.source_range(), label);
+ builder.insert_snippet(cap, snippet).kind(CompletionItemKind::Snippet).clone()
}
pub(crate) fn complete_expr_snippet(acc: &mut Completions, ctx: &CompletionContext) {
None => return,
};
- snippet(
+ let mut test_module_builder = snippet(
ctx,
cap,
"tmod (Test module)",
$0
}
}",
- )
- .lookup_by("tmod")
- .add_to(acc);
+ );
+ test_module_builder.lookup_by("tmod");
+ test_module_builder.add_to(acc);
- snippet(
+ let mut test_function_builder = snippet(
ctx,
cap,
"tfn (Test function)",
fn ${1:feature}() {
$0
}",
- )
- .lookup_by("tfn")
- .add_to(acc);
+ );
+ test_function_builder.lookup_by("tfn");
+ test_function_builder.add_to(acc);
- snippet(ctx, cap, "macro_rules", "macro_rules! $1 {\n\t($2) => {\n\t\t$0\n\t};\n}").add_to(acc);
+ let macro_rules_builder =
+ snippet(ctx, cap, "macro_rules", "macro_rules! $1 {\n\t($2) => {\n\t\t$0\n\t};\n}");
+ macro_rules_builder.add_to(acc);
}
#[cfg(test)]