diff --git a/snippets/rust.cson b/snippets/rust.cson index bf61778..4f2236a 100644 --- a/snippets/rust.cson +++ b/snippets/rust.cson @@ -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})]' @@ -14,6 +20,16 @@ 'derive': 'prefix': 'derive' 'body': '#[derive(${1:Trait})]' + 'Err': + 'prefix': 'Err' + 'body': 'Err($1)' + 'else': + 'prefix': 'else' + 'body': ''' + else { + \t$1 + } + ''' 'enum': 'prefix': 'enum' 'body': ''' @@ -21,6 +37,9 @@ \t$2 } ''' + 'extern crate': + 'prefix': 'extern-crate' + 'body': 'extern crate ${1:name};' 'fn': 'prefix': 'fn' 'body': ''' @@ -42,6 +61,9 @@ \t$3 } ''' + 'format': + 'prefix': 'format' + 'body': 'format!("${1:{${2::?}\\}}", ${3});' 'if': 'prefix': 'if' 'body': ''' @@ -49,6 +71,13 @@ \t$2 } ''' + 'if let': + 'prefix': 'if-let' + 'body': ''' + if let ${1:Some(value)} = ${2:variable} { + \t$3 + } + ''' 'impl': 'prefix': 'impl' 'body': ''' @@ -56,9 +85,19 @@ \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': ''' @@ -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};' @@ -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})]' @@ -147,3 +195,10 @@ \t$2 } ''' + 'while let': + 'prefix': 'while-let' + 'body': ''' + while let ${1:Some(value)} = ${2:variable} { + \t$3 + } + '''