@enjoys/context-engine 1.0.0 → 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/data/commands/adb.json +322 -0
- package/data/commands/alembic.json +301 -0
- package/data/commands/artisan.json +277 -0
- package/data/commands/atlas.json +426 -0
- package/data/commands/auth0.json +648 -0
- package/data/commands/bat.json +84 -0
- package/data/commands/bundle.json +321 -0
- package/data/commands/composer.json +507 -0
- package/data/commands/dart.json +216 -0
- package/data/commands/dbmate.json +257 -0
- package/data/commands/docker-compose.json +384 -0
- package/data/commands/drizzle-kit.json +217 -0
- package/data/commands/expo.json +65 -0
- package/data/commands/fastlane.json +243 -0
- package/data/commands/fd.json +86 -0
- package/data/commands/flutter.json +298 -0
- package/data/commands/flyway.json +261 -0
- package/data/commands/fzf.json +103 -0
- package/data/commands/gem.json +267 -0
- package/data/commands/jq.json +100 -0
- package/data/commands/k9s.json +62 -0
- package/data/commands/liquibase.json +399 -0
- package/data/commands/manifest.json +619 -0
- package/data/commands/minikube.json +60 -0
- package/data/commands/ng.json +64 -0
- package/data/commands/nuxt.json +60 -0
- package/data/commands/php.json +157 -0
- package/data/commands/pm2.json +259 -0
- package/data/commands/pod.json +175 -0
- package/data/commands/prisma.json +257 -0
- package/data/commands/rails.json +372 -0
- package/data/commands/rake.json +360 -0
- package/data/commands/react-native.json +57 -0
- package/data/commands/rg.json +103 -0
- package/data/commands/rspec.json +257 -0
- package/data/commands/ruby.json +108 -0
- package/data/commands/sequelize.json +342 -0
- package/data/commands/snyk.json +442 -0
- package/data/commands/sonar-scanner.json +219 -0
- package/data/commands/stripe.json +314 -0
- package/data/commands/symfony.json +449 -0
- package/data/commands/tmux.json +197 -0
- package/data/commands/trivy.json +367 -0
- package/data/commands/twilio.json +382 -0
- package/data/commands/typeorm.json +262 -0
- package/data/commands/vue.json +60 -0
- package/data/commands/wp.json +857 -0
- package/data/commands/xcodebuild.json +141 -0
- package/data/commands/yq.json +57 -0
- package/data/completion/bash.json +1184 -0
- package/data/completion/c.json +1067 -0
- package/data/completion/cpp.json +824 -0
- package/data/completion/csharp.json +860 -0
- package/data/completion/dockerfile.json +536 -0
- package/data/completion/go.json +1346 -0
- package/data/completion/html.json +806 -0
- package/data/completion/java.json +1112 -0
- package/data/completion/javascript.json +914 -0
- package/data/completion/lua.json +968 -0
- package/data/completion/php.json +1535 -0
- package/data/completion/python.json +1427 -0
- package/data/completion/ruby.json +1531 -0
- package/data/completion/rust.json +698 -0
- package/data/completion/sql.json +887 -0
- package/data/completion/toml.json +428 -0
- package/data/completion/typescript.json +338 -0
- package/data/completion/yaml.json +563 -0
- package/data/defination/bash.json +565 -0
- package/data/defination/c.json +865 -0
- package/data/defination/cpp.json +348 -0
- package/data/defination/csharp.json +144 -0
- package/data/defination/dockerfile.json +113 -0
- package/data/defination/go.json +561 -0
- package/data/defination/html.json +559 -0
- package/data/defination/java.json +184 -0
- package/data/defination/javascript.json +265 -0
- package/data/defination/lua.json +181 -0
- package/data/defination/php.json +726 -0
- package/data/defination/python.json +717 -0
- package/data/defination/ruby.json +670 -0
- package/data/defination/rust.json +207 -0
- package/data/defination/sql.json +473 -0
- package/data/defination/toml.json +251 -0
- package/data/defination/typescript.json +29 -0
- package/data/defination/yaml.json +197 -0
- package/data/hover/bash.json +245 -0
- package/data/hover/c.json +265 -0
- package/data/hover/cpp.json +210 -0
- package/data/hover/csharp.json +290 -0
- package/data/hover/dockerfile.json +145 -0
- package/data/hover/go.json +580 -0
- package/data/hover/html.json +250 -0
- package/data/hover/java.json +395 -0
- package/data/hover/javascript.json +330 -0
- package/data/hover/lua.json +265 -0
- package/data/hover/php.json +300 -0
- package/data/hover/python.json +380 -0
- package/data/hover/ruby.json +265 -0
- package/data/hover/rust.json +275 -0
- package/data/hover/sql.json +230 -0
- package/data/hover/toml.json +145 -0
- package/data/hover/typescript.json +120 -0
- package/data/hover/yaml.json +165 -0
- package/data/manifest.json +242 -0
- package/package.json +1 -1
|
@@ -0,0 +1,698 @@
|
|
|
1
|
+
{
|
|
2
|
+
"language": "rust",
|
|
3
|
+
"completions": [
|
|
4
|
+
{
|
|
5
|
+
"label": "println!",
|
|
6
|
+
"kind": 1,
|
|
7
|
+
"detail": "Print to stdout with newline",
|
|
8
|
+
"documentation": { "value": "Prints to standard output with a newline.\n\n```rust\nprintln!(\"Hello, world!\");\nprintln!(\"x = {}\", x);\nprintln!(\"{name} is {age}\", name=\"Alice\", age=30);\n```" },
|
|
9
|
+
"insertText": "println!(\"${1:format}\", ${2:args});",
|
|
10
|
+
"insertTextRules": 4,
|
|
11
|
+
"sortText": "00_println"
|
|
12
|
+
},
|
|
13
|
+
{
|
|
14
|
+
"label": "eprintln!",
|
|
15
|
+
"kind": 1,
|
|
16
|
+
"detail": "Print to stderr with newline",
|
|
17
|
+
"documentation": { "value": "Prints to standard error with a newline.\n\n```rust\neprintln!(\"Error: {}\", msg);\neprintln!(\"Warning: file not found\");\n```" },
|
|
18
|
+
"insertText": "eprintln!(\"${1:format}\", ${2:args});",
|
|
19
|
+
"insertTextRules": 4,
|
|
20
|
+
"sortText": "00_eprintln"
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
"label": "format!",
|
|
24
|
+
"kind": 1,
|
|
25
|
+
"detail": "Create a formatted String",
|
|
26
|
+
"documentation": { "value": "Creates a `String` using interpolation of runtime expressions.\n\n```rust\nlet s = format!(\"Hello, {}!\", name);\nlet msg = format!(\"{} items found\", count);\nlet addr = format!(\"{}:{}\", host, port);\n```" },
|
|
27
|
+
"insertText": "format!(\"${1:format}\", ${2:args})",
|
|
28
|
+
"insertTextRules": 4,
|
|
29
|
+
"sortText": "00_format"
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
"label": "vec!",
|
|
33
|
+
"kind": 1,
|
|
34
|
+
"detail": "Create a Vec from literal values",
|
|
35
|
+
"documentation": { "value": "Creates a `Vec` containing the arguments.\n\n```rust\nlet v = vec![1, 2, 3];\nlet zeros = vec![0; 10];\nlet names = vec![\"Alice\", \"Bob\"];\n```" },
|
|
36
|
+
"insertText": "vec![${1:elements}]",
|
|
37
|
+
"insertTextRules": 4,
|
|
38
|
+
"sortText": "00_vec"
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
"label": "panic!",
|
|
42
|
+
"kind": 1,
|
|
43
|
+
"detail": "Panic with a message",
|
|
44
|
+
"documentation": { "value": "Panics the current thread with the given message.\n\n```rust\npanic!(\"something went wrong\");\npanic!(\"index out of bounds: {}\", index);\n```" },
|
|
45
|
+
"insertText": "panic!(\"${1:message}\");",
|
|
46
|
+
"insertTextRules": 4,
|
|
47
|
+
"sortText": "00_panic"
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
"label": "assert!",
|
|
51
|
+
"kind": 1,
|
|
52
|
+
"detail": "Assert a boolean condition",
|
|
53
|
+
"documentation": { "value": "Panics if the given expression is false.\n\n```rust\nassert!(x > 0);\nassert!(result.is_ok(), \"Expected Ok, got {:?}\", result);\n```" },
|
|
54
|
+
"insertText": "assert!(${1:condition});",
|
|
55
|
+
"insertTextRules": 4,
|
|
56
|
+
"sortText": "00_assert"
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
"label": "assert_eq!",
|
|
60
|
+
"kind": 1,
|
|
61
|
+
"detail": "Assert two values are equal",
|
|
62
|
+
"documentation": { "value": "Panics if the two expressions are not equal.\n\n```rust\nassert_eq!(a, b);\nassert_eq!(result, 42, \"Expected 42\");\n```" },
|
|
63
|
+
"insertText": "assert_eq!(${1:left}, ${2:right});",
|
|
64
|
+
"insertTextRules": 4,
|
|
65
|
+
"sortText": "00_assert_eq"
|
|
66
|
+
},
|
|
67
|
+
{
|
|
68
|
+
"label": "assert_ne!",
|
|
69
|
+
"kind": 1,
|
|
70
|
+
"detail": "Assert two values are not equal",
|
|
71
|
+
"documentation": { "value": "Panics if the two expressions are equal.\n\n```rust\nassert_ne!(a, b);\nassert_ne!(result, 0, \"Should not be zero\");\n```" },
|
|
72
|
+
"insertText": "assert_ne!(${1:left}, ${2:right});",
|
|
73
|
+
"insertTextRules": 4,
|
|
74
|
+
"sortText": "00_assert_ne"
|
|
75
|
+
},
|
|
76
|
+
{
|
|
77
|
+
"label": "todo!",
|
|
78
|
+
"kind": 1,
|
|
79
|
+
"detail": "Mark unfinished code",
|
|
80
|
+
"documentation": { "value": "Indicates unfinished code. Panics with a \"not yet implemented\" message.\n\n```rust\nfn process() -> Result<()> {\n todo!()\n}\nfn handle(event: Event) {\n todo!(\"handle {:?}\", event)\n}\n```" },
|
|
81
|
+
"insertText": "todo!(\"${1:reason}\")",
|
|
82
|
+
"insertTextRules": 4,
|
|
83
|
+
"sortText": "00_todo"
|
|
84
|
+
},
|
|
85
|
+
{
|
|
86
|
+
"label": "unimplemented!",
|
|
87
|
+
"kind": 1,
|
|
88
|
+
"detail": "Mark unimplemented code",
|
|
89
|
+
"documentation": { "value": "Indicates unimplemented code by panicking.\n\n```rust\nfn serialize(&self) -> Vec<u8> {\n unimplemented!()\n}\n```" },
|
|
90
|
+
"insertText": "unimplemented!()",
|
|
91
|
+
"insertTextRules": 4,
|
|
92
|
+
"sortText": "00_unimplemented"
|
|
93
|
+
},
|
|
94
|
+
{
|
|
95
|
+
"label": "dbg!",
|
|
96
|
+
"kind": 1,
|
|
97
|
+
"detail": "Debug print and return value",
|
|
98
|
+
"documentation": { "value": "Prints the value to stderr with file and line info and returns it.\n\n```rust\nlet x = dbg!(2 + 3);\ndbg!(&my_vec);\n```" },
|
|
99
|
+
"insertText": "dbg!(${1:expr})",
|
|
100
|
+
"insertTextRules": 4,
|
|
101
|
+
"sortText": "00_dbg"
|
|
102
|
+
},
|
|
103
|
+
{
|
|
104
|
+
"label": "write!",
|
|
105
|
+
"kind": 1,
|
|
106
|
+
"detail": "Write formatted data into a buffer",
|
|
107
|
+
"documentation": { "value": "Writes formatted data into a buffer implementing `std::fmt::Write` or `std::io::Write`.\n\n```rust\nuse std::fmt::Write;\nlet mut buf = String::new();\nwrite!(buf, \"Hello, {}!\", name)?;\n```" },
|
|
108
|
+
"insertText": "write!(${1:buf}, \"${2:format}\", ${3:args})",
|
|
109
|
+
"insertTextRules": 4,
|
|
110
|
+
"sortText": "00_write"
|
|
111
|
+
},
|
|
112
|
+
{
|
|
113
|
+
"label": "writeln!",
|
|
114
|
+
"kind": 1,
|
|
115
|
+
"detail": "Write formatted data with newline",
|
|
116
|
+
"documentation": { "value": "Same as `write!` but appends a newline.\n\n```rust\nwriteln!(buf, \"line: {}\", i)?;\nwriteln!(f, \"{}: {}\", key, value)?;\n```" },
|
|
117
|
+
"insertText": "writeln!(${1:buf}, \"${2:format}\", ${3:args})",
|
|
118
|
+
"insertTextRules": 4,
|
|
119
|
+
"sortText": "00_writeln"
|
|
120
|
+
},
|
|
121
|
+
{
|
|
122
|
+
"label": "include_str!",
|
|
123
|
+
"kind": 1,
|
|
124
|
+
"detail": "Include a file as a string",
|
|
125
|
+
"documentation": { "value": "Includes a UTF-8 encoded file as a string at compile time.\n\n```rust\nlet contents = include_str!(\"data.txt\");\nlet sql = include_str!(\"../migrations/001.sql\");\n```" },
|
|
126
|
+
"insertText": "include_str!(\"${1:path}\")",
|
|
127
|
+
"insertTextRules": 4,
|
|
128
|
+
"sortText": "00_include_str"
|
|
129
|
+
},
|
|
130
|
+
{
|
|
131
|
+
"label": "include_bytes!",
|
|
132
|
+
"kind": 1,
|
|
133
|
+
"detail": "Include a file as bytes",
|
|
134
|
+
"documentation": { "value": "Includes a file as a byte array at compile time.\n\n```rust\nlet data = include_bytes!(\"image.png\");\nlet cert = include_bytes!(\"cert.pem\");\n```" },
|
|
135
|
+
"insertText": "include_bytes!(\"${1:path}\")",
|
|
136
|
+
"insertTextRules": 4,
|
|
137
|
+
"sortText": "00_include_bytes"
|
|
138
|
+
},
|
|
139
|
+
{
|
|
140
|
+
"label": "concat!",
|
|
141
|
+
"kind": 1,
|
|
142
|
+
"detail": "Concatenate literals into a static string",
|
|
143
|
+
"documentation": { "value": "Concatenates literals into a `&'static str`.\n\n```rust\nlet s = concat!(\"Hello\", \", \", \"world!\");\nlet version = concat!(\"v\", env!(\"CARGO_PKG_VERSION\"));\n```" },
|
|
144
|
+
"insertText": "concat!(${1:literals})",
|
|
145
|
+
"insertTextRules": 4,
|
|
146
|
+
"sortText": "00_concat"
|
|
147
|
+
},
|
|
148
|
+
{
|
|
149
|
+
"label": "cfg!",
|
|
150
|
+
"kind": 1,
|
|
151
|
+
"detail": "Evaluate configuration flags at compile time",
|
|
152
|
+
"documentation": { "value": "Evaluates configuration flags at compile time and returns a bool.\n\n```rust\nif cfg!(target_os = \"linux\") {\n println!(\"Running on Linux\");\n}\nif cfg!(debug_assertions) {\n println!(\"Debug mode\");\n}\n```" },
|
|
153
|
+
"insertText": "cfg!(${1:flag})",
|
|
154
|
+
"insertTextRules": 4,
|
|
155
|
+
"sortText": "00_cfg"
|
|
156
|
+
},
|
|
157
|
+
{
|
|
158
|
+
"label": "env!",
|
|
159
|
+
"kind": 1,
|
|
160
|
+
"detail": "Read environment variable at compile time",
|
|
161
|
+
"documentation": { "value": "Inspects an environment variable at compile time.\n\n```rust\nlet version = env!(\"CARGO_PKG_VERSION\");\nlet name = env!(\"CARGO_PKG_NAME\");\n```" },
|
|
162
|
+
"insertText": "env!(\"${1:VAR}\")",
|
|
163
|
+
"insertTextRules": 4,
|
|
164
|
+
"sortText": "00_env"
|
|
165
|
+
},
|
|
166
|
+
{
|
|
167
|
+
"label": "matches!",
|
|
168
|
+
"kind": 1,
|
|
169
|
+
"detail": "Check if expression matches a pattern",
|
|
170
|
+
"documentation": { "value": "Returns a bool indicating whether an expression matches any of the given patterns.\n\n```rust\nlet is_vowel = matches!(c, 'a' | 'e' | 'i' | 'o' | 'u');\nlet is_some = matches!(opt, Some(_));\n```" },
|
|
171
|
+
"insertText": "matches!(${1:expr}, ${2:pattern})",
|
|
172
|
+
"insertTextRules": 4,
|
|
173
|
+
"sortText": "00_matches"
|
|
174
|
+
},
|
|
175
|
+
{
|
|
176
|
+
"label": "compile_error!",
|
|
177
|
+
"kind": 1,
|
|
178
|
+
"detail": "Emit a compile-time error",
|
|
179
|
+
"documentation": { "value": "Causes compilation to fail with the given error message.\n\n```rust\n#[cfg(not(any(feature = \"a\", feature = \"b\")))]\ncompile_error!(\"Either feature 'a' or 'b' must be enabled\");\n```" },
|
|
180
|
+
"insertText": "compile_error!(\"${1:message}\");",
|
|
181
|
+
"insertTextRules": 4,
|
|
182
|
+
"sortText": "00_compile_error"
|
|
183
|
+
},
|
|
184
|
+
{
|
|
185
|
+
"label": "fn",
|
|
186
|
+
"kind": 14,
|
|
187
|
+
"detail": "Function definition",
|
|
188
|
+
"documentation": { "value": "Defines a function.\n\n```rust\nfn add(a: i32, b: i32) -> i32 {\n a + b\n}\nfn greet(name: &str) {\n println!(\"Hello, {}!\", name);\n}\n```" },
|
|
189
|
+
"insertText": "fn ${1:name}(${2:params}) -> ${3:ReturnType} {\n ${4:body}\n}",
|
|
190
|
+
"insertTextRules": 4,
|
|
191
|
+
"sortText": "01_fn"
|
|
192
|
+
},
|
|
193
|
+
{
|
|
194
|
+
"label": "let",
|
|
195
|
+
"kind": 14,
|
|
196
|
+
"detail": "Variable binding (immutable)",
|
|
197
|
+
"documentation": { "value": "Creates an immutable variable binding.\n\n```rust\nlet x = 5;\nlet name: String = String::from(\"Alice\");\nlet (a, b) = (1, 2);\n```" },
|
|
198
|
+
"insertText": "let ${1:name} = ${2:value};",
|
|
199
|
+
"insertTextRules": 4,
|
|
200
|
+
"sortText": "01_let"
|
|
201
|
+
},
|
|
202
|
+
{
|
|
203
|
+
"label": "let mut",
|
|
204
|
+
"kind": 14,
|
|
205
|
+
"detail": "Mutable variable binding",
|
|
206
|
+
"documentation": { "value": "Creates a mutable variable binding.\n\n```rust\nlet mut count = 0;\ncount += 1;\nlet mut buf = Vec::new();\n```" },
|
|
207
|
+
"insertText": "let mut ${1:name} = ${2:value};",
|
|
208
|
+
"insertTextRules": 4,
|
|
209
|
+
"sortText": "01_let_mut"
|
|
210
|
+
},
|
|
211
|
+
{
|
|
212
|
+
"label": "struct",
|
|
213
|
+
"kind": 14,
|
|
214
|
+
"detail": "Struct definition",
|
|
215
|
+
"documentation": { "value": "Defines a struct type.\n\n```rust\nstruct Point {\n x: f64,\n y: f64,\n}\nstruct Color(u8, u8, u8); // tuple struct\nstruct Unit; // unit struct\n```" },
|
|
216
|
+
"insertText": "struct ${1:Name} {\n ${2:field}: ${3:Type},\n}",
|
|
217
|
+
"insertTextRules": 4,
|
|
218
|
+
"sortText": "01_struct"
|
|
219
|
+
},
|
|
220
|
+
{
|
|
221
|
+
"label": "enum",
|
|
222
|
+
"kind": 14,
|
|
223
|
+
"detail": "Enum definition",
|
|
224
|
+
"documentation": { "value": "Defines an enum type.\n\n```rust\nenum Direction {\n Up,\n Down,\n Left,\n Right,\n}\nenum Message {\n Quit,\n Text(String),\n Move { x: i32, y: i32 },\n}\n```" },
|
|
225
|
+
"insertText": "enum ${1:Name} {\n ${2:Variant},\n}",
|
|
226
|
+
"insertTextRules": 4,
|
|
227
|
+
"sortText": "01_enum"
|
|
228
|
+
},
|
|
229
|
+
{
|
|
230
|
+
"label": "impl",
|
|
231
|
+
"kind": 14,
|
|
232
|
+
"detail": "Implementation block",
|
|
233
|
+
"documentation": { "value": "Defines methods and associated functions for a type.\n\n```rust\nimpl Point {\n fn new(x: f64, y: f64) -> Self {\n Self { x, y }\n }\n fn distance(&self, other: &Point) -> f64 {\n ((self.x - other.x).powi(2) + (self.y - other.y).powi(2)).sqrt()\n }\n}\n```" },
|
|
234
|
+
"insertText": "impl ${1:Type} {\n ${2:methods}\n}",
|
|
235
|
+
"insertTextRules": 4,
|
|
236
|
+
"sortText": "01_impl"
|
|
237
|
+
},
|
|
238
|
+
{
|
|
239
|
+
"label": "trait",
|
|
240
|
+
"kind": 14,
|
|
241
|
+
"detail": "Trait definition",
|
|
242
|
+
"documentation": { "value": "Defines a trait (interface).\n\n```rust\ntrait Summary {\n fn summarize(&self) -> String;\n fn headline(&self) -> String {\n String::from(\"(Read more...)\")\n }\n}\n```" },
|
|
243
|
+
"insertText": "trait ${1:Name} {\n fn ${2:method}(&self) -> ${3:ReturnType};\n}",
|
|
244
|
+
"insertTextRules": 4,
|
|
245
|
+
"sortText": "01_trait"
|
|
246
|
+
},
|
|
247
|
+
{
|
|
248
|
+
"label": "pub",
|
|
249
|
+
"kind": 14,
|
|
250
|
+
"detail": "Public visibility modifier",
|
|
251
|
+
"documentation": { "value": "Makes an item accessible from outside the current module.\n\n```rust\npub fn public_function() {}\npub struct PublicStruct { pub field: i32 }\npub(crate) fn crate_only() {}\npub(super) fn parent_only() {}\n```" },
|
|
252
|
+
"insertText": "pub ",
|
|
253
|
+
"insertTextRules": 4,
|
|
254
|
+
"sortText": "01_pub"
|
|
255
|
+
},
|
|
256
|
+
{
|
|
257
|
+
"label": "mod",
|
|
258
|
+
"kind": 14,
|
|
259
|
+
"detail": "Module declaration",
|
|
260
|
+
"documentation": { "value": "Declares a module.\n\n```rust\nmod utils;\nmod tests {\n use super::*;\n #[test]\n fn test_add() {\n assert_eq!(add(2, 3), 5);\n }\n}\n```" },
|
|
261
|
+
"insertText": "mod ${1:name} {\n ${2:body}\n}",
|
|
262
|
+
"insertTextRules": 4,
|
|
263
|
+
"sortText": "01_mod"
|
|
264
|
+
},
|
|
265
|
+
{
|
|
266
|
+
"label": "use",
|
|
267
|
+
"kind": 14,
|
|
268
|
+
"detail": "Use declaration / import",
|
|
269
|
+
"documentation": { "value": "Brings items into scope.\n\n```rust\nuse std::collections::HashMap;\nuse std::io::{self, Read, Write};\nuse crate::models::User;\n```" },
|
|
270
|
+
"insertText": "use ${1:path};",
|
|
271
|
+
"insertTextRules": 4,
|
|
272
|
+
"sortText": "01_use"
|
|
273
|
+
},
|
|
274
|
+
{
|
|
275
|
+
"label": "match",
|
|
276
|
+
"kind": 14,
|
|
277
|
+
"detail": "Match expression",
|
|
278
|
+
"documentation": { "value": "Pattern matching on a value.\n\n```rust\nmatch value {\n 0 => println!(\"zero\"),\n 1..=9 => println!(\"single digit\"),\n _ => println!(\"other\"),\n}\nmatch result {\n Ok(val) => val,\n Err(e) => return Err(e),\n}\n```" },
|
|
279
|
+
"insertText": "match ${1:expr} {\n ${2:pattern} => ${3:result},\n _ => ${4:default},\n}",
|
|
280
|
+
"insertTextRules": 4,
|
|
281
|
+
"sortText": "01_match"
|
|
282
|
+
},
|
|
283
|
+
{
|
|
284
|
+
"label": "if let",
|
|
285
|
+
"kind": 14,
|
|
286
|
+
"detail": "Conditional pattern match",
|
|
287
|
+
"documentation": { "value": "Combines `if` with pattern matching.\n\n```rust\nif let Some(val) = optional {\n println!(\"Got: {}\", val);\n}\nif let Ok(n) = \"42\".parse::<i32>() {\n println!(\"parsed: {}\", n);\n}\n```" },
|
|
288
|
+
"insertText": "if let ${1:Some(val)} = ${2:expr} {\n ${3:body}\n}",
|
|
289
|
+
"insertTextRules": 4,
|
|
290
|
+
"sortText": "01_if_let"
|
|
291
|
+
},
|
|
292
|
+
{
|
|
293
|
+
"label": "while let",
|
|
294
|
+
"kind": 14,
|
|
295
|
+
"detail": "Loop with pattern match",
|
|
296
|
+
"documentation": { "value": "Loops while a pattern matches.\n\n```rust\nwhile let Some(item) = stack.pop() {\n process(item);\n}\nwhile let Ok(line) = reader.read_line(&mut buf) {\n println!(\"{}\", line);\n}\n```" },
|
|
297
|
+
"insertText": "while let ${1:Some(val)} = ${2:expr} {\n ${3:body}\n}",
|
|
298
|
+
"insertTextRules": 4,
|
|
299
|
+
"sortText": "01_while_let"
|
|
300
|
+
},
|
|
301
|
+
{
|
|
302
|
+
"label": "loop",
|
|
303
|
+
"kind": 14,
|
|
304
|
+
"detail": "Infinite loop",
|
|
305
|
+
"documentation": { "value": "Creates an infinite loop. Use `break` to exit.\n\n```rust\nloop {\n let input = read_input();\n if input == \"quit\" {\n break;\n }\n process(input);\n}\nlet result = loop {\n if done() { break 42; }\n};\n```" },
|
|
306
|
+
"insertText": "loop {\n ${1:body}\n}",
|
|
307
|
+
"insertTextRules": 4,
|
|
308
|
+
"sortText": "01_loop"
|
|
309
|
+
},
|
|
310
|
+
{
|
|
311
|
+
"label": "for..in",
|
|
312
|
+
"kind": 14,
|
|
313
|
+
"detail": "For loop over iterator",
|
|
314
|
+
"documentation": { "value": "Iterates over an iterator.\n\n```rust\nfor item in &vec {\n println!(\"{}\", item);\n}\nfor i in 0..10 {\n println!(\"{}\", i);\n}\nfor (i, val) in vec.iter().enumerate() {\n println!(\"{}: {}\", i, val);\n}\n```" },
|
|
315
|
+
"insertText": "for ${1:item} in ${2:iter} {\n ${3:body}\n}",
|
|
316
|
+
"insertTextRules": 4,
|
|
317
|
+
"sortText": "01_for_in"
|
|
318
|
+
},
|
|
319
|
+
{
|
|
320
|
+
"label": "async fn",
|
|
321
|
+
"kind": 14,
|
|
322
|
+
"detail": "Async function definition",
|
|
323
|
+
"documentation": { "value": "Defines an async function that returns a `Future`.\n\n```rust\nasync fn fetch(url: &str) -> Result<String, Error> {\n let resp = reqwest::get(url).await?;\n resp.text().await\n}\n```" },
|
|
324
|
+
"insertText": "async fn ${1:name}(${2:params}) -> ${3:ReturnType} {\n ${4:body}\n}",
|
|
325
|
+
"insertTextRules": 4,
|
|
326
|
+
"sortText": "01_async_fn"
|
|
327
|
+
},
|
|
328
|
+
{
|
|
329
|
+
"label": ".await",
|
|
330
|
+
"kind": 14,
|
|
331
|
+
"detail": "Await a future",
|
|
332
|
+
"documentation": { "value": "Suspends execution until the future is ready.\n\n```rust\nlet result = some_async_fn().await;\nlet body = response.text().await?;\n```" },
|
|
333
|
+
"insertText": ".await",
|
|
334
|
+
"insertTextRules": 4,
|
|
335
|
+
"sortText": "01_await"
|
|
336
|
+
},
|
|
337
|
+
{
|
|
338
|
+
"label": "return",
|
|
339
|
+
"kind": 14,
|
|
340
|
+
"detail": "Return from function",
|
|
341
|
+
"documentation": { "value": "Returns a value from the current function.\n\n```rust\nfn check(x: i32) -> bool {\n if x < 0 { return false; }\n true\n}\n```" },
|
|
342
|
+
"insertText": "return ${1:value};",
|
|
343
|
+
"insertTextRules": 4,
|
|
344
|
+
"sortText": "01_return"
|
|
345
|
+
},
|
|
346
|
+
{
|
|
347
|
+
"label": "type",
|
|
348
|
+
"kind": 14,
|
|
349
|
+
"detail": "Type alias",
|
|
350
|
+
"documentation": { "value": "Creates a type alias.\n\n```rust\ntype Result<T> = std::result::Result<T, MyError>;\ntype Callback = Box<dyn Fn(i32) -> i32>;\n```" },
|
|
351
|
+
"insertText": "type ${1:Name} = ${2:Type};",
|
|
352
|
+
"insertTextRules": 4,
|
|
353
|
+
"sortText": "01_type"
|
|
354
|
+
},
|
|
355
|
+
{
|
|
356
|
+
"label": "where",
|
|
357
|
+
"kind": 14,
|
|
358
|
+
"detail": "Where clause for generics",
|
|
359
|
+
"documentation": { "value": "Specifies trait bounds in a where clause.\n\n```rust\nfn process<T>(item: T) -> String\nwhere\n T: Display + Clone,\n{\n format!(\"{}\", item)\n}\n```" },
|
|
360
|
+
"insertText": "where\n ${1:T}: ${2:Trait},",
|
|
361
|
+
"insertTextRules": 4,
|
|
362
|
+
"sortText": "01_where"
|
|
363
|
+
},
|
|
364
|
+
{
|
|
365
|
+
"label": "const",
|
|
366
|
+
"kind": 14,
|
|
367
|
+
"detail": "Compile-time constant",
|
|
368
|
+
"documentation": { "value": "Declares a compile-time constant.\n\n```rust\nconst MAX_SIZE: usize = 1024;\nconst PI: f64 = 3.14159265358979;\n```" },
|
|
369
|
+
"insertText": "const ${1:NAME}: ${2:Type} = ${3:value};",
|
|
370
|
+
"insertTextRules": 4,
|
|
371
|
+
"sortText": "01_const"
|
|
372
|
+
},
|
|
373
|
+
{
|
|
374
|
+
"label": "static",
|
|
375
|
+
"kind": 14,
|
|
376
|
+
"detail": "Static variable",
|
|
377
|
+
"documentation": { "value": "Declares a static variable with a `'static` lifetime.\n\n```rust\nstatic COUNTER: AtomicUsize = AtomicUsize::new(0);\nstatic CONFIG: &str = \"default\";\n```" },
|
|
378
|
+
"insertText": "static ${1:NAME}: ${2:Type} = ${3:value};",
|
|
379
|
+
"insertTextRules": 4,
|
|
380
|
+
"sortText": "01_static"
|
|
381
|
+
},
|
|
382
|
+
{
|
|
383
|
+
"label": "unsafe",
|
|
384
|
+
"kind": 14,
|
|
385
|
+
"detail": "Unsafe block",
|
|
386
|
+
"documentation": { "value": "Marks a block or function as unsafe, allowing raw pointer dereferences and other unsafe operations.\n\n```rust\nunsafe {\n let val = *raw_ptr;\n}\nunsafe fn dangerous() { }\n```" },
|
|
387
|
+
"insertText": "unsafe {\n ${1:body}\n}",
|
|
388
|
+
"insertTextRules": 4,
|
|
389
|
+
"sortText": "01_unsafe"
|
|
390
|
+
},
|
|
391
|
+
{
|
|
392
|
+
"label": "extern",
|
|
393
|
+
"kind": 14,
|
|
394
|
+
"detail": "Extern block for FFI",
|
|
395
|
+
"documentation": { "value": "Declares an external function interface.\n\n```rust\nextern \"C\" {\n fn abs(input: i32) -> i32;\n}\n```" },
|
|
396
|
+
"insertText": "extern \"C\" {\n fn ${1:name}(${2:params}) -> ${3:ReturnType};\n}",
|
|
397
|
+
"insertTextRules": 4,
|
|
398
|
+
"sortText": "01_extern"
|
|
399
|
+
},
|
|
400
|
+
{
|
|
401
|
+
"label": "ref",
|
|
402
|
+
"kind": 14,
|
|
403
|
+
"detail": "Bind by reference in patterns",
|
|
404
|
+
"documentation": { "value": "Binds by reference during pattern matching.\n\n```rust\nlet ref x = 5; // x: &i32\nmatch value {\n ref v => println!(\"{}\", v),\n}\n```" },
|
|
405
|
+
"insertText": "ref ${1:name}",
|
|
406
|
+
"insertTextRules": 4,
|
|
407
|
+
"sortText": "01_ref"
|
|
408
|
+
},
|
|
409
|
+
{
|
|
410
|
+
"label": "dyn",
|
|
411
|
+
"kind": 14,
|
|
412
|
+
"detail": "Dynamic dispatch trait object",
|
|
413
|
+
"documentation": { "value": "Specifies a trait object type with dynamic dispatch.\n\n```rust\nfn log(writer: &dyn Write) { }\nlet handler: Box<dyn Fn()> = Box::new(|| println!(\"hi\"));\n```" },
|
|
414
|
+
"insertText": "dyn ${1:Trait}",
|
|
415
|
+
"insertTextRules": 4,
|
|
416
|
+
"sortText": "01_dyn"
|
|
417
|
+
},
|
|
418
|
+
{
|
|
419
|
+
"label": "Box::new",
|
|
420
|
+
"kind": 1,
|
|
421
|
+
"detail": "Allocate value on the heap",
|
|
422
|
+
"documentation": { "value": "Allocates memory on the heap and places the value into it.\n\n```rust\nlet b = Box::new(5);\nlet s = Box::new(String::from(\"hello\"));\nlet trait_obj: Box<dyn Display> = Box::new(42);\n```" },
|
|
423
|
+
"insertText": "Box::new(${1:value})",
|
|
424
|
+
"insertTextRules": 4,
|
|
425
|
+
"sortText": "02_box_new"
|
|
426
|
+
},
|
|
427
|
+
{
|
|
428
|
+
"label": "String::new",
|
|
429
|
+
"kind": 1,
|
|
430
|
+
"detail": "Create an empty String",
|
|
431
|
+
"documentation": { "value": "Creates a new empty `String`.\n\n```rust\nlet mut s = String::new();\ns.push_str(\"hello\");\n```" },
|
|
432
|
+
"insertText": "String::new()",
|
|
433
|
+
"insertTextRules": 4,
|
|
434
|
+
"sortText": "02_string_new"
|
|
435
|
+
},
|
|
436
|
+
{
|
|
437
|
+
"label": "String::from",
|
|
438
|
+
"kind": 1,
|
|
439
|
+
"detail": "Create a String from a &str",
|
|
440
|
+
"documentation": { "value": "Converts a `&str` into a `String`.\n\n```rust\nlet s = String::from(\"hello\");\nlet greeting = String::from(\"Hello, world!\");\n```" },
|
|
441
|
+
"insertText": "String::from(\"${1:text}\")",
|
|
442
|
+
"insertTextRules": 4,
|
|
443
|
+
"sortText": "02_string_from"
|
|
444
|
+
},
|
|
445
|
+
{
|
|
446
|
+
"label": "Vec::new",
|
|
447
|
+
"kind": 1,
|
|
448
|
+
"detail": "Create an empty Vec",
|
|
449
|
+
"documentation": { "value": "Constructs a new, empty `Vec<T>`.\n\n```rust\nlet mut v: Vec<i32> = Vec::new();\nv.push(1);\n```" },
|
|
450
|
+
"insertText": "Vec::new()",
|
|
451
|
+
"insertTextRules": 4,
|
|
452
|
+
"sortText": "02_vec_new"
|
|
453
|
+
},
|
|
454
|
+
{
|
|
455
|
+
"label": "Vec::with_capacity",
|
|
456
|
+
"kind": 1,
|
|
457
|
+
"detail": "Create a Vec with preallocated capacity",
|
|
458
|
+
"documentation": { "value": "Constructs a new, empty `Vec<T>` with the specified capacity.\n\n```rust\nlet mut v = Vec::with_capacity(100);\nv.push(42);\nassert!(v.capacity() >= 100);\n```" },
|
|
459
|
+
"insertText": "Vec::with_capacity(${1:capacity})",
|
|
460
|
+
"insertTextRules": 4,
|
|
461
|
+
"sortText": "02_vec_with_capacity"
|
|
462
|
+
},
|
|
463
|
+
{
|
|
464
|
+
"label": "HashMap::new",
|
|
465
|
+
"kind": 1,
|
|
466
|
+
"detail": "Create an empty HashMap",
|
|
467
|
+
"documentation": { "value": "Creates an empty `HashMap`.\n\n```rust\nuse std::collections::HashMap;\nlet mut map = HashMap::new();\nmap.insert(\"key\", \"value\");\n```" },
|
|
468
|
+
"insertText": "HashMap::new()",
|
|
469
|
+
"insertTextRules": 4,
|
|
470
|
+
"sortText": "02_hashmap_new"
|
|
471
|
+
},
|
|
472
|
+
{
|
|
473
|
+
"label": "HashSet::new",
|
|
474
|
+
"kind": 1,
|
|
475
|
+
"detail": "Create an empty HashSet",
|
|
476
|
+
"documentation": { "value": "Creates an empty `HashSet`.\n\n```rust\nuse std::collections::HashSet;\nlet mut set = HashSet::new();\nset.insert(42);\n```" },
|
|
477
|
+
"insertText": "HashSet::new()",
|
|
478
|
+
"insertTextRules": 4,
|
|
479
|
+
"sortText": "02_hashset_new"
|
|
480
|
+
},
|
|
481
|
+
{
|
|
482
|
+
"label": "BTreeMap::new",
|
|
483
|
+
"kind": 1,
|
|
484
|
+
"detail": "Create an empty BTreeMap",
|
|
485
|
+
"documentation": { "value": "Creates an empty `BTreeMap` (sorted map).\n\n```rust\nuse std::collections::BTreeMap;\nlet mut map = BTreeMap::new();\nmap.insert(1, \"one\");\n```" },
|
|
486
|
+
"insertText": "BTreeMap::new()",
|
|
487
|
+
"insertTextRules": 4,
|
|
488
|
+
"sortText": "02_btreemap_new"
|
|
489
|
+
},
|
|
490
|
+
{
|
|
491
|
+
"label": "Option::Some",
|
|
492
|
+
"kind": 1,
|
|
493
|
+
"detail": "Wrap a value in Some",
|
|
494
|
+
"documentation": { "value": "Creates an `Option` containing a value.\n\n```rust\nlet x: Option<i32> = Some(42);\nlet name = Some(String::from(\"Alice\"));\n```" },
|
|
495
|
+
"insertText": "Some(${1:value})",
|
|
496
|
+
"insertTextRules": 4,
|
|
497
|
+
"sortText": "02_option_some"
|
|
498
|
+
},
|
|
499
|
+
{
|
|
500
|
+
"label": "Option::None",
|
|
501
|
+
"kind": 1,
|
|
502
|
+
"detail": "No value",
|
|
503
|
+
"documentation": { "value": "Represents the absence of a value.\n\n```rust\nlet x: Option<i32> = None;\nfn find(id: u32) -> Option<&User> { None }\n```" },
|
|
504
|
+
"insertText": "None",
|
|
505
|
+
"insertTextRules": 4,
|
|
506
|
+
"sortText": "02_option_none"
|
|
507
|
+
},
|
|
508
|
+
{
|
|
509
|
+
"label": "Result::Ok",
|
|
510
|
+
"kind": 1,
|
|
511
|
+
"detail": "Success result",
|
|
512
|
+
"documentation": { "value": "Contains the success value.\n\n```rust\nlet r: Result<i32, String> = Ok(42);\nfn parse(s: &str) -> Result<i32, ParseIntError> { Ok(0) }\n```" },
|
|
513
|
+
"insertText": "Ok(${1:value})",
|
|
514
|
+
"insertTextRules": 4,
|
|
515
|
+
"sortText": "02_result_ok"
|
|
516
|
+
},
|
|
517
|
+
{
|
|
518
|
+
"label": "Result::Err",
|
|
519
|
+
"kind": 1,
|
|
520
|
+
"detail": "Error result",
|
|
521
|
+
"documentation": { "value": "Contains the error value.\n\n```rust\nlet r: Result<i32, String> = Err(\"failed\".into());\nreturn Err(MyError::NotFound);\n```" },
|
|
522
|
+
"insertText": "Err(${1:error})",
|
|
523
|
+
"insertTextRules": 4,
|
|
524
|
+
"sortText": "02_result_err"
|
|
525
|
+
},
|
|
526
|
+
{
|
|
527
|
+
"label": "Rc::new",
|
|
528
|
+
"kind": 1,
|
|
529
|
+
"detail": "Create a new reference-counted pointer",
|
|
530
|
+
"documentation": { "value": "Constructs a new `Rc<T>` (single-threaded reference counting).\n\n```rust\nuse std::rc::Rc;\nlet shared = Rc::new(vec![1, 2, 3]);\nlet clone = Rc::clone(&shared);\n```" },
|
|
531
|
+
"insertText": "Rc::new(${1:value})",
|
|
532
|
+
"insertTextRules": 4,
|
|
533
|
+
"sortText": "02_rc_new"
|
|
534
|
+
},
|
|
535
|
+
{
|
|
536
|
+
"label": "Arc::new",
|
|
537
|
+
"kind": 1,
|
|
538
|
+
"detail": "Create a new atomic reference-counted pointer",
|
|
539
|
+
"documentation": { "value": "Constructs a new `Arc<T>` (thread-safe reference counting).\n\n```rust\nuse std::sync::Arc;\nlet shared = Arc::new(data);\nlet clone = Arc::clone(&shared);\n```" },
|
|
540
|
+
"insertText": "Arc::new(${1:value})",
|
|
541
|
+
"insertTextRules": 4,
|
|
542
|
+
"sortText": "02_arc_new"
|
|
543
|
+
},
|
|
544
|
+
{
|
|
545
|
+
"label": "Mutex::new",
|
|
546
|
+
"kind": 1,
|
|
547
|
+
"detail": "Create a new mutex",
|
|
548
|
+
"documentation": { "value": "Creates a new `Mutex<T>`.\n\n```rust\nuse std::sync::Mutex;\nlet m = Mutex::new(0);\nlet mut val = m.lock().unwrap();\n*val += 1;\n```" },
|
|
549
|
+
"insertText": "Mutex::new(${1:value})",
|
|
550
|
+
"insertTextRules": 4,
|
|
551
|
+
"sortText": "02_mutex_new"
|
|
552
|
+
},
|
|
553
|
+
{
|
|
554
|
+
"label": "Cell::new",
|
|
555
|
+
"kind": 1,
|
|
556
|
+
"detail": "Create a new Cell",
|
|
557
|
+
"documentation": { "value": "Creates a new `Cell<T>` for interior mutability of `Copy` types.\n\n```rust\nuse std::cell::Cell;\nlet c = Cell::new(5);\nc.set(10);\nassert_eq!(c.get(), 10);\n```" },
|
|
558
|
+
"insertText": "Cell::new(${1:value})",
|
|
559
|
+
"insertTextRules": 4,
|
|
560
|
+
"sortText": "02_cell_new"
|
|
561
|
+
},
|
|
562
|
+
{
|
|
563
|
+
"label": "RefCell::new",
|
|
564
|
+
"kind": 1,
|
|
565
|
+
"detail": "Create a new RefCell",
|
|
566
|
+
"documentation": { "value": "Creates a new `RefCell<T>` for interior mutability with runtime borrow checking.\n\n```rust\nuse std::cell::RefCell;\nlet c = RefCell::new(vec![1, 2, 3]);\nc.borrow_mut().push(4);\n```" },
|
|
567
|
+
"insertText": "RefCell::new(${1:value})",
|
|
568
|
+
"insertTextRules": 4,
|
|
569
|
+
"sortText": "02_refcell_new"
|
|
570
|
+
},
|
|
571
|
+
{
|
|
572
|
+
"label": "#[derive(...)]",
|
|
573
|
+
"kind": 14,
|
|
574
|
+
"detail": "Derive trait implementations",
|
|
575
|
+
"documentation": { "value": "Automatically implements traits for a type.\n\n```rust\n#[derive(Debug, Clone, PartialEq)]\nstruct Point { x: f64, y: f64 }\n\n#[derive(Debug, Clone, Copy, Hash, Eq, PartialEq)]\nenum Color { Red, Green, Blue }\n\n#[derive(Default, serde::Serialize, serde::Deserialize)]\nstruct Config { port: u16, host: String }\n```" },
|
|
576
|
+
"insertText": "#[derive(${1:Debug, Clone, PartialEq})]",
|
|
577
|
+
"insertTextRules": 4,
|
|
578
|
+
"sortText": "03_derive"
|
|
579
|
+
},
|
|
580
|
+
{
|
|
581
|
+
"label": "impl Trait for Type",
|
|
582
|
+
"kind": 14,
|
|
583
|
+
"detail": "Implement a trait for a type",
|
|
584
|
+
"documentation": { "value": "Implements a trait for a specific type.\n\n```rust\nimpl Display for Point {\n fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {\n write!(f, \"({}, {})\", self.x, self.y)\n }\n}\nimpl From<&str> for MyType {\n fn from(s: &str) -> Self { MyType(s.to_string()) }\n}\n```" },
|
|
585
|
+
"insertText": "impl ${1:Trait} for ${2:Type} {\n ${3:methods}\n}",
|
|
586
|
+
"insertTextRules": 4,
|
|
587
|
+
"sortText": "03_impl_trait"
|
|
588
|
+
},
|
|
589
|
+
{
|
|
590
|
+
"label": "match arms",
|
|
591
|
+
"kind": 14,
|
|
592
|
+
"detail": "Match with multiple arms",
|
|
593
|
+
"documentation": { "value": "Pattern matching with multiple arms.\n\n```rust\nmatch command {\n Command::Quit => break,\n Command::Echo(msg) => println!(\"{}\", msg),\n Command::Move { x, y } => move_to(x, y),\n _ => eprintln!(\"Unknown command\"),\n}\n```" },
|
|
594
|
+
"insertText": "match ${1:expr} {\n ${2:Pattern1} => ${3:expr1},\n ${4:Pattern2} => ${5:expr2},\n _ => ${6:default},\n}",
|
|
595
|
+
"insertTextRules": 4,
|
|
596
|
+
"sortText": "03_match_arms"
|
|
597
|
+
},
|
|
598
|
+
{
|
|
599
|
+
"label": "? (error propagation)",
|
|
600
|
+
"kind": 14,
|
|
601
|
+
"detail": "Propagate errors with ?",
|
|
602
|
+
"documentation": { "value": "The `?` operator propagates errors. If the value is `Err`, it returns early.\n\n```rust\nfn read_config(path: &str) -> Result<Config, Box<dyn Error>> {\n let contents = std::fs::read_to_string(path)?;\n let config: Config = serde_json::from_str(&contents)?;\n Ok(config)\n}\n```" },
|
|
603
|
+
"insertText": "${1:expr}?",
|
|
604
|
+
"insertTextRules": 4,
|
|
605
|
+
"sortText": "03_question_mark"
|
|
606
|
+
},
|
|
607
|
+
{
|
|
608
|
+
"label": "closure",
|
|
609
|
+
"kind": 14,
|
|
610
|
+
"detail": "Closure (anonymous function)",
|
|
611
|
+
"documentation": { "value": "Creates a closure.\n\n```rust\nlet add = |a, b| a + b;\nlet double = |x: i32| -> i32 { x * 2 };\nvec.iter().filter(|x| **x > 5).collect::<Vec<_>>();\nvec.sort_by(|a, b| a.cmp(b));\n```" },
|
|
612
|
+
"insertText": "|${1:params}| ${2:body}",
|
|
613
|
+
"insertTextRules": 4,
|
|
614
|
+
"sortText": "03_closure"
|
|
615
|
+
},
|
|
616
|
+
{
|
|
617
|
+
"label": "async/await",
|
|
618
|
+
"kind": 14,
|
|
619
|
+
"detail": "Async block with await",
|
|
620
|
+
"documentation": { "value": "Creates an async block.\n\n```rust\nlet future = async {\n let data = fetch(\"http://example.com\").await?;\n process(data).await\n};\n```" },
|
|
621
|
+
"insertText": "async {\n let ${1:result} = ${2:future}.await${3:?};\n ${4:body}\n}",
|
|
622
|
+
"insertTextRules": 4,
|
|
623
|
+
"sortText": "03_async_await"
|
|
624
|
+
},
|
|
625
|
+
{
|
|
626
|
+
"label": "lifetime annotation",
|
|
627
|
+
"kind": 14,
|
|
628
|
+
"detail": "Lifetime annotation",
|
|
629
|
+
"documentation": { "value": "Annotates lifetimes to help the borrow checker.\n\n```rust\nfn longest<'a>(x: &'a str, y: &'a str) -> &'a str {\n if x.len() > y.len() { x } else { y }\n}\nstruct Excerpt<'a> {\n part: &'a str,\n}\n```" },
|
|
630
|
+
"insertText": "<'${1:a}>",
|
|
631
|
+
"insertTextRules": 4,
|
|
632
|
+
"sortText": "03_lifetime"
|
|
633
|
+
},
|
|
634
|
+
{
|
|
635
|
+
"label": "Display trait",
|
|
636
|
+
"kind": 8,
|
|
637
|
+
"detail": "Implement Display for custom formatting",
|
|
638
|
+
"documentation": { "value": "Format trait for the `{}` marker. Used by `println!`, `format!`, etc.\n\n```rust\nuse std::fmt;\nimpl fmt::Display for Point {\n fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {\n write!(f, \"({}, {})\", self.x, self.y)\n }\n}\n```" },
|
|
639
|
+
"insertText": "impl fmt::Display for ${1:Type} {\n fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {\n write!(f, \"${2:format}\", ${3:self.field})\n }\n}",
|
|
640
|
+
"insertTextRules": 4,
|
|
641
|
+
"sortText": "04_display"
|
|
642
|
+
},
|
|
643
|
+
{
|
|
644
|
+
"label": "Debug trait",
|
|
645
|
+
"kind": 8,
|
|
646
|
+
"detail": "Implement Debug for debug formatting",
|
|
647
|
+
"documentation": { "value": "Format trait for the `{:?}` marker. Usually derived.\n\n```rust\n#[derive(Debug)]\nstruct Point { x: f64, y: f64 }\nprintln!(\"{:?}\", point);\nprintln!(\"{:#?}\", point); // pretty-print\n```" },
|
|
648
|
+
"insertText": "#[derive(Debug)]",
|
|
649
|
+
"insertTextRules": 4,
|
|
650
|
+
"sortText": "04_debug"
|
|
651
|
+
},
|
|
652
|
+
{
|
|
653
|
+
"label": "Clone trait",
|
|
654
|
+
"kind": 8,
|
|
655
|
+
"detail": "Derive or implement Clone",
|
|
656
|
+
"documentation": { "value": "A trait for explicitly duplicating a value.\n\n```rust\n#[derive(Clone)]\nstruct Config { name: String, port: u16 }\nlet copy = config.clone();\n```" },
|
|
657
|
+
"insertText": "#[derive(Clone)]",
|
|
658
|
+
"insertTextRules": 4,
|
|
659
|
+
"sortText": "04_clone"
|
|
660
|
+
},
|
|
661
|
+
{
|
|
662
|
+
"label": "Default trait",
|
|
663
|
+
"kind": 8,
|
|
664
|
+
"detail": "Derive or implement Default",
|
|
665
|
+
"documentation": { "value": "A trait for creating a default value.\n\n```rust\n#[derive(Default)]\nstruct Config { port: u16, debug: bool }\nlet cfg = Config::default();\nlet cfg = Config { port: 8080, ..Default::default() };\n```" },
|
|
666
|
+
"insertText": "#[derive(Default)]",
|
|
667
|
+
"insertTextRules": 4,
|
|
668
|
+
"sortText": "04_default"
|
|
669
|
+
},
|
|
670
|
+
{
|
|
671
|
+
"label": "Iterator trait",
|
|
672
|
+
"kind": 8,
|
|
673
|
+
"detail": "Implement Iterator",
|
|
674
|
+
"documentation": { "value": "A trait for dealing with iterators.\n\n```rust\nimpl Iterator for Counter {\n type Item = u32;\n fn next(&mut self) -> Option<Self::Item> {\n if self.count < 5 {\n self.count += 1;\n Some(self.count)\n } else {\n None\n }\n }\n}\n```" },
|
|
675
|
+
"insertText": "impl Iterator for ${1:Type} {\n type Item = ${2:ItemType};\n fn next(&mut self) -> Option<Self::Item> {\n ${3:body}\n }\n}",
|
|
676
|
+
"insertTextRules": 4,
|
|
677
|
+
"sortText": "04_iterator"
|
|
678
|
+
},
|
|
679
|
+
{
|
|
680
|
+
"label": "From trait",
|
|
681
|
+
"kind": 8,
|
|
682
|
+
"detail": "Implement From for type conversion",
|
|
683
|
+
"documentation": { "value": "Used for value-to-value conversion. Implementing `From` automatically provides `Into`.\n\n```rust\nimpl From<&str> for MyString {\n fn from(s: &str) -> Self {\n MyString(s.to_string())\n }\n}\nlet s: MyString = \"hello\".into();\n```" },
|
|
684
|
+
"insertText": "impl From<${1:SourceType}> for ${2:TargetType} {\n fn from(${3:val}: ${1:SourceType}) -> Self {\n ${4:body}\n }\n}",
|
|
685
|
+
"insertTextRules": 4,
|
|
686
|
+
"sortText": "04_from"
|
|
687
|
+
},
|
|
688
|
+
{
|
|
689
|
+
"label": "Drop trait",
|
|
690
|
+
"kind": 8,
|
|
691
|
+
"detail": "Implement Drop for cleanup",
|
|
692
|
+
"documentation": { "value": "Custom code to run when a value goes out of scope.\n\n```rust\nimpl Drop for TempFile {\n fn drop(&mut self) {\n std::fs::remove_file(&self.path).ok();\n }\n}\n```" },
|
|
693
|
+
"insertText": "impl Drop for ${1:Type} {\n fn drop(&mut self) {\n ${2:cleanup}\n }\n}",
|
|
694
|
+
"insertTextRules": 4,
|
|
695
|
+
"sortText": "04_drop"
|
|
696
|
+
}
|
|
697
|
+
]
|
|
698
|
+
}
|