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

Add more snippets to rust.cson #130

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 55 additions & 0 deletions snippets/rust.cson
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@
'allow!':
'prefix': 'allow!'
'body': '#![allow(${1:lint})]'
'assert':
'prefix': 'assert'
'body': 'assert!($1);'
'assert_eq':
'prefix': 'assert_eq'
'body': 'assert_eq!($1, $2);'
'deny':
'prefix': 'deny'
'body': '#[deny(${1:lint})]'
Expand All @@ -14,13 +20,26 @@
'derive':
'prefix': 'derive'
'body': '#[derive(${1:Trait})]'
'Err':
'prefix': 'Err'
'body': 'Err($1)'
'else':
'prefix': 'else'
'body': '''
else {
\t$1
}
'''
'enum':
'prefix': 'enum'
'body': '''
enum ${1:TypeName} {
\t$2
}
'''
'extern crate':
'prefix': 'extern-crate'
'body': 'extern crate ${1:name};'
'fn':
'prefix': 'fn'
'body': '''
Expand All @@ -42,23 +61,43 @@
\t$3
}
'''
'format':
'prefix': 'format'
'body': 'format!("${1:{${2::?}\\}}", ${3});'
'if':
'prefix': 'if'
'body': '''
if ${1:expression} {
\t$2
}
'''
'if let':
'prefix': 'if-let'
'body': '''
if let ${1:Some(value)} = ${2:variable} {
\t$3
}
'''
'impl':
'prefix': 'impl'
'body': '''
impl ${1:TypeName} {
\t$2
}
'''
'impl for':
'prefix': 'impl-for'
'body': '''
impl ${1:Trait} for ${2:TypeName} {
\t$3
}
'''
'let':
'prefix': 'let'
'body': 'let ${1:variable} = ${2:value};'
'let mut':
'prefix': 'letm'
'body': 'let mut ${1:variable} = ${2:value};'
'loop':
'prefix': 'loop'
'body': '''
Expand Down Expand Up @@ -87,12 +126,18 @@
\t$2
}
'''
'Ok':
'prefix': 'Ok'
'body': 'Ok($1)'
'print':
'prefix': 'print'
'body': 'print!("${1:{${2::?}\\}}", ${3});'
'println':
'prefix': 'println'
'body': 'println!("${1:{${2::?}\\}}", ${3});'
'Some':
'prefix': 'Some'
'body': 'Some($1)'
'static':
'prefix': 'static'
'body': 'static ${1:CONSTANT}: ${2:TypeName} = ${3:value};'
Expand Down Expand Up @@ -134,6 +179,9 @@
'type':
'prefix': 'type'
'body': 'type ${1:TypeName} = ${2:TypeName};'
'use':
'prefix': 'use'
'body': 'use ${1:name};'
'warn':
'prefix': 'warn'
'body': '#[warn(${1:lint})]'
Expand All @@ -147,3 +195,10 @@
\t$2
}
'''
'while let':
'prefix': 'while-let'
'body': '''
while let ${1:Some(value)} = ${2:variable} {
\t$3
}
'''