Use dot notation for enum variants
This commit is contained in:
parent
ab783c33ed
commit
117d188194
13 changed files with 162 additions and 154 deletions
|
|
@ -67,13 +67,13 @@
|
|||
"prefix": "match",
|
||||
"body": [
|
||||
"match (${1:result}) {",
|
||||
" ${2:Result}::${3:Success}(${4:value}) -> {",
|
||||
" ${2:Result}.${3:Success}(${4:value}) -> {",
|
||||
" $5",
|
||||
" }",
|
||||
" ${2:Result}::${6:Failure}(${7:reason}) -> {",
|
||||
" ${2:Result}.${6:Failure}(${7:reason}) -> {",
|
||||
" $8",
|
||||
" }",
|
||||
" ${2:Result}::${9:Pending} -> {",
|
||||
" ${2:Result}.${9:Pending} -> {",
|
||||
" $0",
|
||||
" }",
|
||||
"}"
|
||||
|
|
@ -84,8 +84,8 @@
|
|||
"prefix": "matchvalue",
|
||||
"body": [
|
||||
"val ${1:value} = match (${2:result}) {",
|
||||
" ${3:Result}::${4:Success}(${5:item}) -> ${5:item}",
|
||||
" ${3:Result}::${6:Failure}(${7:reason}) -> ${7:reason}",
|
||||
" ${3:Result}.${4:Success}(${5:item}) -> ${5:item}",
|
||||
" ${3:Result}.${6:Failure}(${7:reason}) -> ${7:reason}",
|
||||
" $0",
|
||||
"}"
|
||||
],
|
||||
|
|
@ -111,7 +111,7 @@
|
|||
"body": [
|
||||
"fun ${1:name}(${2}): Result<${3:Value}, Error> {",
|
||||
" val ${4:value} = ${5:operation}()?",
|
||||
" return Result::Ok(${4:value})",
|
||||
" return Result.Ok(${4:value})",
|
||||
"}"
|
||||
],
|
||||
"description": "Function with Rust-style Result propagation"
|
||||
|
|
@ -120,8 +120,8 @@
|
|||
"prefix": "resultmatch",
|
||||
"body": [
|
||||
"match (${1:result}) {",
|
||||
" Result::Ok(${2:value}) -> { $3 }",
|
||||
" Result::Err(${4:error}) -> { $0 }",
|
||||
" Result.Ok(${2:value}) -> { $3 }",
|
||||
" Result.Err(${4:error}) -> { $0 }",
|
||||
"}"
|
||||
],
|
||||
"description": "Match a Result value"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue