File: rust.snippets

package info (click to toggle)
vim-snippets 1.0.0-8
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 900 kB
  • sloc: python: 9; makefile: 2
file content (125 lines) | stat: -rw-r--r-- 2,103 bytes parent folder | download | duplicates (4)
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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
#################
# Rust Snippets #
#################

# Functions
snippet fn
	fn ${1:function_name}(${2}) {
		${0}
	}
snippet fn-
	fn ${1:function_name}(${2}) -> ${3} {
		${0}
	}
snippet test
	#[test]
	fn ${1:test_function_name}() {
		${0}
	}
snippet new
	pub fn new(${2}) -> ${1:Name} {
		${0}return $1 { ${3} };
	}
snippet main
	pub fn main() {
		${0}
	}
snippet let
	let ${1:name}${3} = ${2};
snippet pln
	println!("${1}");
snippet pln,
	println!("${1}", ${2});
snippet ec
	extern crate ${1:sync};
snippet ecl
	#![feature(phase)]
	#[phase(syntax, link)] extern crate log;
snippet mod
	mod ${1:`substitute(vim_snippets#Filename(), '\(_\|^\)\(.\)', '\u\2', 'g')`} {
		${0}
	} /* $1 */
snippet crate
	// Crate ID
	#![crate_id = "${1:crate_name}#${2:0.0.1}"]
	// Additional metadata attributes
	#![desc = "${3:Descrption.}"]
	#![license = "${4:BSD}"]
	#![comment = "${5:Comment.}"]
	// Specify the output type
	#![crate_type = "${6:lib}"]
snippet allow
	#[allow(${1:unused_variable})]
snippet feat
	#![feature(${1:macro_rules})]
# Common types
snippet opt
	Option<${1:int}>
snippet res
	Result<${1:~str}, ${2:()}>
snippet if
	if ${1:/* condition */} {
		${0}
	}
snippet mat
	match ${1} {
		${2} => ${3},
	}
snippet while
	while ${1:condition} {
		${0}
	}
snippet for
	for ${1:i} in ${2:range(0u, 10)} {
		${0}
	}
snippet spawn
	spawn(proc() {
		${0}
	});
snippet chan
	let (${1:tx}, ${2:rx}): (Sender<${3:int}>, Receiver<${4:int}>) = channel();
snippet duplex
	let (${1:from_child}, ${2:to_child}) = sync::duplex();
# TODO commenting
snippet todo
	// [TODO]: ${1:Description}
# Struct
snippet st
	struct ${1:`substitute(vim_snippets#Filename(), '\(_\|^\)\(.\)', '\u\2', 'g')`} {
		${0}
	}

	impl $1 {
		pub fn new(${2}) -> $1 {
			${4}return $1 {
				${5}
			};
		}
	}
# Enum
snippet enum
	enum ${1:enum_name} {
		${0},
	}
# Impl
snippet imp
	impl ${1:Name} {
		${0}
	}
snippet drop
	impl Drop for ${1:Name} {
		fn drop(&mut self) {
			${0}
		}
	}
# Traits
snippet trait
	trait ${1:Name} {
		${0}
	}
# Statics
snippet ss
	static ${1}: &'static str = "${0}";
snippet stat
	static ${1}: ${2:uint} = ${0};