7928: Add completion to turn x.err into Err(x) r=matklad a=duongdominhchau

PR for issue #7925 

Co-authored-by: Duong Do Minh Chau <duongdominhchau@gmail.com>
This commit is contained in:
bors[bot] 2021-03-09 11:13:17 +00:00 committed by GitHub
commit 297240744d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -183,6 +183,16 @@ pub(crate) fn complete_postfix(acc: &mut Completions, ctx: &CompletionContext) {
postfix_snippet(ctx, cap, &dot_receiver, "ok", "Ok(expr)", &format!("Ok({})", receiver_text))
.add_to(acc);
postfix_snippet(
ctx,
cap,
&dot_receiver,
"err",
"Err(expr)",
&format!("Err({})", receiver_text),
)
.add_to(acc);
postfix_snippet(
ctx,
cap,
@ -325,6 +335,7 @@ fn main() {
sn match match expr {}
sn box Box::new(expr)
sn ok Ok(expr)
sn err Err(expr)
sn some Some(expr)
sn dbg dbg!(expr)
sn dbgr dbg!(&expr)
@ -357,6 +368,7 @@ fn main() {
sn match match expr {}
sn box Box::new(expr)
sn ok Ok(expr)
sn err Err(expr)
sn some Some(expr)
sn dbg dbg!(expr)
sn dbgr dbg!(&expr)
@ -380,6 +392,7 @@ fn main() {
sn match match expr {}
sn box Box::new(expr)
sn ok Ok(expr)
sn err Err(expr)
sn some Some(expr)
sn dbg dbg!(expr)
sn dbgr dbg!(&expr)
@ -408,6 +421,7 @@ fn main() {
sn match match expr {}
sn box Box::new(expr)
sn ok Ok(expr)
sn err Err(expr)
sn some Some(expr)
sn dbg dbg!(expr)
sn dbgr dbg!(&expr)