Auto merge of #15730 - Alainx277:let-else-postfix, r=Veykril
Add postfix completion for let else Adds a postfix completion for let else syntax, similar to the if let postfix.
This commit is contained in:
commit
d13951f25c
@ -84,6 +84,13 @@ pub(crate) fn complete_postfix(
|
||||
)
|
||||
.add_to(acc, ctx.db);
|
||||
|
||||
postfix_snippet(
|
||||
"lete",
|
||||
"let Ok else {}",
|
||||
&format!("let Ok($1) = {receiver_text} else {{\n $2\n}};\n$0"),
|
||||
)
|
||||
.add_to(acc, ctx.db);
|
||||
|
||||
postfix_snippet(
|
||||
"while",
|
||||
"while let Ok {}",
|
||||
@ -99,6 +106,13 @@ pub(crate) fn complete_postfix(
|
||||
)
|
||||
.add_to(acc, ctx.db);
|
||||
|
||||
postfix_snippet(
|
||||
"lete",
|
||||
"let Some else {}",
|
||||
&format!("let Some($1) = {receiver_text} else {{\n $2\n}};\n$0"),
|
||||
)
|
||||
.add_to(acc, ctx.db);
|
||||
|
||||
postfix_snippet(
|
||||
"while",
|
||||
"while let Some {}",
|
||||
@ -469,6 +483,29 @@ fn main() {
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn option_letelse() {
|
||||
check_edit(
|
||||
"lete",
|
||||
r#"
|
||||
//- minicore: option
|
||||
fn main() {
|
||||
let bar = Some(true);
|
||||
bar.$0
|
||||
}
|
||||
"#,
|
||||
r#"
|
||||
fn main() {
|
||||
let bar = Some(true);
|
||||
let Some($1) = bar else {
|
||||
$2
|
||||
};
|
||||
$0
|
||||
}
|
||||
"#,
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn result_match() {
|
||||
check_edit(
|
||||
|
Loading…
Reference in New Issue
Block a user