Skip to content
This repository was archived by the owner on Nov 18, 2022. It is now read-only.

Commit 47771a5

Browse files
committed
Generalize if let snippet to work with any enum variant
1 parent 56eee57 commit 47771a5

File tree

2 files changed

+5
-6
lines changed

2 files changed

+5
-6
lines changed

README.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,7 @@ the following snippets:
7474

7575
* `for` - a for loop
7676
* `macro_rules` - declare a macro
77-
* `if let Option` - an `if let` statement for executing code only in the `Some`
78-
case.
77+
* `if let` - an `if let` statement for executing code only when a pattern matches
7978
* `spawn` - spawn a thread
8079
* `extern crate` - insert an `extern crate` statement
8180

snippets/rust.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,14 @@
2626
],
2727
"description": "Insert macro_rules!"
2828
},
29-
"if let Option": {
29+
"if let": {
3030
"prefix": "if let",
3131
"body": [
32-
"if let Some(${1:foo}) = ${1:foo} {",
33-
"\t${0:${1:foo}.}",
32+
"if let ${1:pattern} = ${2:value} {",
33+
"\t$3",
3434
"}"
3535
],
36-
"description": "Unwrap Option with if let"
36+
"description": "Insert if to match a specific pattern, useful for enum variants e.g. `Some(inner)`"
3737
},
3838
"spawn": {
3939
"prefix": [

0 commit comments

Comments
 (0)