File tree 1 file changed +37
-0
lines changed
crates/ide-completion/src/completions
1 file changed +37
-0
lines changed Original file line number Diff line number Diff line change @@ -84,6 +84,13 @@ pub(crate) fn complete_postfix(
84
84
)
85
85
. add_to ( acc, ctx. db ) ;
86
86
87
+ postfix_snippet (
88
+ "lete" ,
89
+ "let Ok else {}" ,
90
+ & format ! ( "let Ok($1) = {receiver_text} else {{\n $2\n }};\n $0" ) ,
91
+ )
92
+ . add_to ( acc, ctx. db ) ;
93
+
87
94
postfix_snippet (
88
95
"while" ,
89
96
"while let Ok {}" ,
@@ -99,6 +106,13 @@ pub(crate) fn complete_postfix(
99
106
)
100
107
. add_to ( acc, ctx. db ) ;
101
108
109
+ postfix_snippet (
110
+ "lete" ,
111
+ "let Some else {}" ,
112
+ & format ! ( "let Some($1) = {receiver_text} else {{\n $2\n }};\n $0" ) ,
113
+ )
114
+ . add_to ( acc, ctx. db ) ;
115
+
102
116
postfix_snippet (
103
117
"while" ,
104
118
"while let Some {}" ,
@@ -469,6 +483,29 @@ fn main() {
469
483
) ;
470
484
}
471
485
486
+ #[ test]
487
+ fn option_letelse ( ) {
488
+ check_edit (
489
+ "lete" ,
490
+ r#"
491
+ //- minicore: option
492
+ fn main() {
493
+ let bar = Some(true);
494
+ bar.$0
495
+ }
496
+ "# ,
497
+ r#"
498
+ fn main() {
499
+ let bar = Some(true);
500
+ let Some($1) = bar else {
501
+ $2
502
+ };
503
+ $0
504
+ }
505
+ "# ,
506
+ ) ;
507
+ }
508
+
472
509
#[ test]
473
510
fn result_match ( ) {
474
511
check_edit (
You can’t perform that action at this time.
0 commit comments