Skip to content
This repository was archived by the owner on Mar 19, 2024. It is now read-only.

Commit 598602c

Browse files
sunjayalexheretic
authored andcommitted
Add snippets from language-rust to ide-rust (#112)
1 parent bdb9126 commit 598602c

File tree

1 file changed

+149
-0
lines changed

1 file changed

+149
-0
lines changed

snippets/rust.cson

Lines changed: 149 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,149 @@
1+
'.source.rust':
2+
'allow':
3+
'prefix': 'allow'
4+
'body': '#[allow(${1:lint})]'
5+
'allow!':
6+
'prefix': 'allow!'
7+
'body': '#![allow(${1:lint})]'
8+
'deny':
9+
'prefix': 'deny'
10+
'body': '#[deny(${1:lint})]'
11+
'deny!':
12+
'prefix': 'deny!'
13+
'body': '#![deny(${1:lint})]'
14+
'derive':
15+
'prefix': 'derive'
16+
'body': '#[derive(${1:Trait})]'
17+
'enum':
18+
'prefix': 'enum'
19+
'body': '''
20+
enum ${1:TypeName} {
21+
\t$2
22+
}
23+
'''
24+
'fn':
25+
'prefix': 'fn'
26+
'body': '''
27+
fn ${1:function_name}($2) {
28+
\t${3:unimplemented!()}
29+
}
30+
'''
31+
'fnr':
32+
'prefix': 'fnr'
33+
'body': '''
34+
fn ${1:function_name}($2) -> ${3:TypeName} {
35+
\t${4:unimplemented!()}
36+
}
37+
'''
38+
'for':
39+
'prefix': 'for'
40+
'body': '''
41+
for ${1:variable} in ${2:iterator} {
42+
\t$3
43+
}
44+
'''
45+
'if':
46+
'prefix': 'if'
47+
'body': '''
48+
if ${1:expression} {
49+
\t$2
50+
}
51+
'''
52+
'impl':
53+
'prefix': 'impl'
54+
'body': '''
55+
impl ${1:TypeName} {
56+
\t$2
57+
}
58+
'''
59+
'let':
60+
'prefix': 'let'
61+
'body': 'let ${1:variable} = ${2:value};'
62+
'loop':
63+
'prefix': 'loop'
64+
'body': '''
65+
loop {
66+
\t$1
67+
}
68+
'''
69+
'macro':
70+
'prefix': 'macro'
71+
'body': '''
72+
macro_rules! ${1:macro_name} {
73+
\t($2) => ($3);
74+
}
75+
'''
76+
'main':
77+
'prefix': 'main'
78+
'body': '''
79+
fn main() {
80+
\t${1:unimplemented!()}
81+
}
82+
'''
83+
'match':
84+
'prefix': 'match'
85+
'body': '''
86+
match ${1:expression} {
87+
\t$2
88+
}
89+
'''
90+
'print':
91+
'prefix': 'print'
92+
'body': 'print!("${1:{${2::?}\\}}", ${3});'
93+
'println':
94+
'prefix': 'println'
95+
'body': 'println!("${1:{${2::?}\\}}", ${3});'
96+
'static':
97+
'prefix': 'static'
98+
'body': 'static ${1:CONSTANT}: ${2:TypeName} = ${3:value};'
99+
'struct':
100+
'prefix': 'struct'
101+
'body': '''
102+
struct ${1:TypeName} {
103+
\t$2
104+
}
105+
'''
106+
'test':
107+
'prefix': 'test'
108+
'body': '''
109+
#[test]
110+
fn ${1:test_name}() {
111+
\t${2:unimplemented!()}
112+
}
113+
'''
114+
'testmod':
115+
'prefix': 'testmod'
116+
'body': '''
117+
#[cfg(test)]
118+
mod tests {
119+
\tuse super::*;
120+
121+
\t#[test]
122+
\tfn ${1:test_name}() {
123+
\t\t${2:unimplemented!()}
124+
\t}
125+
}
126+
'''
127+
'trait':
128+
'prefix': 'trait'
129+
'body': '''
130+
trait ${1:TypeName} {
131+
\t$2
132+
}
133+
'''
134+
'type':
135+
'prefix': 'type'
136+
'body': 'type ${1:TypeName} = ${2:TypeName};'
137+
'warn':
138+
'prefix': 'warn'
139+
'body': '#[warn(${1:lint})]'
140+
'warn!':
141+
'prefix': 'warn!'
142+
'body': '#![warn(${1:lint})]'
143+
'while':
144+
'prefix': 'while'
145+
'body': '''
146+
while ${1:expression} {
147+
\t$2
148+
}
149+
'''

0 commit comments

Comments
 (0)