4
4
5
5
priority -50
6
6
7
- # ##############
8
- # Functions #
9
- # ##############
10
7
snippet fn " A function, optionally with arguments and return type." b
11
8
fn ${1: function_name } (${2} )${3 / .. * / -> / }${3} {
12
9
${VISUAL}${0}
@@ -20,6 +17,16 @@ fn ${1:test_function_name}() {
20
17
}
21
18
endsnippet
22
19
20
+
21
+ snippet bench " Bench function" b
22
+ #[bench]
23
+ fn ${1: bench_function_name } (b: &mut test::Bencher) {
24
+ b.iter(|| {
25
+ ${VISUAL}${0}
26
+ })
27
+ }
28
+ endsnippet
29
+
23
30
snippet new " A new function" b
24
31
pub fn new(${2} ) -> ${1: Name } {
25
32
${VISUAL}${0} return $1 { ${3} };
@@ -32,17 +39,33 @@ pub fn main() {
32
39
}
33
40
endsnippet
34
41
35
-
36
-
37
42
snippet let " A let statement" b
38
43
let ${1: name } ${3} = ${VISUAL}${2} ;
39
44
endsnippet
40
45
46
+ snippet lmut " let mut = .." b
47
+ let mut ${1: name } ${3} = ${VISUAL}${2} ;
48
+ endsnippet
49
+
50
+ snippet pri " print!(..)" b
51
+ print!("${1} "${2 / .. * / , / }${2} );
52
+ endsnippet
53
+
41
54
snippet pln " println!(..)" b
42
55
println!("${1} "${2 / .. * / , / }${2} );
43
56
endsnippet
44
57
58
+ snippet fmt " format!(..)"
59
+ format!("${1} "${2 / .. * / , / }${2} );
60
+ endsnippet
45
61
62
+ snippet macro " macro_rules!" b
63
+ macro_rules! ${1: name } (
64
+ (${2: matcher } ) => (
65
+ ${3}
66
+ )
67
+ )
68
+ endsnippet
46
69
47
70
snippet ec " extern crate ..." b
48
71
extern crate ${1: sync } ;
@@ -53,10 +76,10 @@ snippet ecl "...extern crate log;" b
53
76
#[phase(syntax, link)] extern crate log;
54
77
endsnippet
55
78
56
- snippet mod " A mod. " b
79
+ snippet mod " A module " b
57
80
mod ${1: `!p snip.rv = snip.basename.lower() or "name"` } {
58
81
${VISUAL}${0}
59
- } /* $1 */
82
+ }
60
83
endsnippet
61
84
62
85
snippet crate " Create header information" b
@@ -80,35 +103,58 @@ snippet feat "#![feature(..)]" b
80
103
#![feature(${1: macro_rules } )]
81
104
endsnippet
82
105
106
+ snippet der " #![deriving(..)]" b
107
+ #![deriving(${1: Show } )]
108
+ endsnippet
83
109
84
- # #################
85
- # Common types #
86
- # #################
87
110
snippet opt " Option<..>"
88
111
Option<${1: int } >
89
112
endsnippet
90
113
91
114
snippet res " Result<.., ..>"
92
- Result<${1: ~str } , ${2: () } >
115
+ Result<${1: int } , ${2: () } >
93
116
endsnippet
94
117
118
+ snippet if " if .. (if)" b
119
+ if ${1} {
120
+ ${VISUAL}${0}
121
+ }
122
+ endsnippet
95
123
124
+ snippet el " else .. (el)"
125
+ else {
126
+ ${VISUAL}${0}
127
+ }
128
+ endsnippet
96
129
97
-
98
- snippet if " if .. (if)" b
99
- if ${1: /* condition */ } {
130
+ snippet eli " else if .. (eli)"
131
+ else if ${1} {
100
132
${VISUAL}${0}
101
133
}
102
134
endsnippet
103
135
136
+ snippet ife " if .. else (ife)"
137
+ if ${1} {
138
+ ${2}
139
+ } else {
140
+ ${3}
141
+ }
142
+ endsnippet
143
+
104
144
snippet mat " match"
105
145
match ${1} {
106
146
${2} => ${3} ,
107
147
}
108
148
endsnippet
109
149
150
+ snippet loop " loop {}" b
151
+ loop {
152
+ ${VISUAL}${0}
153
+ }
154
+ endsnippet
155
+
110
156
snippet while " while .. {}" b
111
- while ${1: condition } {
157
+ while ${1} {
112
158
${VISUAL}${0}
113
159
}
114
160
endsnippet
@@ -133,25 +179,22 @@ snippet duplex "Duplex stream" b
133
179
let (${1: from_child } , ${2: to_child } ) = sync::duplex();
134
180
endsnippet
135
181
136
- # ####################
137
- # TODO commenting #
138
- # ####################
139
182
snippet todo " A Todo comment"
140
183
// [TODO]: ${1: Description } - `!v strftime (" %Y-%m-%d %I:%M%P" ) `
141
184
endsnippet
142
185
186
+ snippet fixme " FIXME comment"
187
+ // FIXME: ${1}
188
+ endsnippet
143
189
144
- # ###########
145
- # Struct #
146
- # ###########
147
190
snippet st " Struct" b
148
- struct ${1: `!p snip.rv = snip.basename.title() or "name "` } {
191
+ struct ${1: `!p snip.rv = snip.basename.title() or "Name "` } {
149
192
${VISUAL}${0}
150
193
}
151
194
endsnippet
152
195
153
196
snippet stn " Struct with new constructor." b
154
- pub struct ${1: `!p snip.rv = snip.basename.title() or "name "` } {
197
+ pub struct ${1: `!p snip.rv = snip.basename.title() or "Name "` } {
155
198
${3}
156
199
}
157
200
@@ -164,20 +207,16 @@ impl $1 {
164
207
}
165
208
endsnippet
166
209
167
-
168
- # #########
169
- # Enum #
170
- # #########
171
210
snippet enum " An enum" b
172
- enum ${1: enum_name } {
211
+ enum ${1: Name } {
173
212
${VISUAL}${0} ,
174
213
}
175
214
endsnippet
176
215
216
+ snippet type " A type" b
217
+ type ${1: NewName } = ${VISUAL}${0} ;
218
+ endsnippet
177
219
178
- # #########
179
- # Impl #
180
- # #########
181
220
snippet imp " An impl" b
182
221
impl ${1: Name } {
183
222
${VISUAL}${0}
@@ -192,20 +231,12 @@ impl Drop for ${1:Name} {
192
231
}
193
232
endsnippet
194
233
195
-
196
- # ###########
197
- # Traits #
198
- # ###########
199
- snippet trait " Trait block" b
234
+ snippet trait " Trait definition" b
200
235
trait ${1: Name } {
201
236
${VISUAL}${0}
202
237
}
203
238
endsnippet
204
239
205
-
206
- # ############
207
- # Statics #
208
- # ############
209
240
snippet ss " A static string."
210
241
static ${1} : &'static str = "${VISUAL}${0} ";
211
242
endsnippet
0 commit comments