-
Notifications
You must be signed in to change notification settings - Fork 1
/
trusty-rusty-snippets.txt
69 lines (63 loc) · 1.98 KB
/
trusty-rusty-snippets.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
trusty-rusty-snippets
A fairly comprehensive set of snippets for the Rust programming language.
Simple short and effective trigger strings. Attention was paid to putting tab stops in all the right places. For example, fn, struct, and enum snippets have the first tab stop before the keyword just in case you might want to add pub (i often forget).
Features
Most rust keywords have simple two letter triggers, i.e. the first two letters of the keyword itself, making them dead easy to recall. (Of course these expand to more than just the keyword).
im => impl
el => else
en => enum
fo => for
fn => fn
if => if
le => let
ma => match
mo => mod
st => struct
tr => trait
ty => type
us => use
In addition, some of the triggers above have modifier letters postfixed for more elaborate expansions.
eni => enum with impl
eng => generic enum
enig => generic enum with impl
ife => if with else
ifl => if let
imf => impl T for Q
img => generic impl
lem => let mut
ler => let ref
lerm => let ref mut
mob => mod name {...} (b for brackets)
sti => struct with impl
stg => generic struct
stig => generic struct with impl
trg => generic trait
tyg => generic type
usa => use as
usb => use module::{...} (b for brackets)
us* => use module::*
There are also a few other helpers and odds and ends.
ec => extern crate
eca => extern crate as
opt => Option<...>
res => Result<...>
| => multiline lambda
main => main function def
new => new constructor def
# => #[...(...)]
cfg => #[cfg(...)]
cff => #[cfg(feature="...")]
drv => #[derive(...))]
drv* => derive common attrs
ass => assert!(...) (pardon my french)
asse => assert_eq!(...)
mr => macro_rules!
pdb => println!("... = {:?}", ...) (print debug)
un => unimplemented!() // TODO
vec => vec![...]
test => #[test] with function def
testm => #[cfg(test)] with module def
todo => // TODO: ...
Feedback
Feedback and suggestions appreciated. Snippets you are missing? I missed a good tab stop? Something is terribly wrong? Or you'd just like to buy me a pizza?
Contact me or submit pull requests.