Commit e7aa936
committed
add code blocks to
Allow writing `_: { /* any number of statements */ }` in initializers to
run arbitrary code during initialization. It also allows declaring
values that can be used later in the initializer:
init!(MyStruct {
_: {
let val = if check_something() {
42
} else {
0
};
},
foo: Foo::new(val),
})
Signed-off-by: Benno Lossin <[email protected]>[try_][pin_]init! macros1 parent 5d2996b commit e7aa936
File tree
2 files changed
+29
-1
lines changed- src
- tests/ui/compile-fail/init
2 files changed
+29
-1
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1202 | 1202 | | |
1203 | 1203 | | |
1204 | 1204 | | |
| 1205 | + | |
| 1206 | + | |
| 1207 | + | |
| 1208 | + | |
| 1209 | + | |
| 1210 | + | |
| 1211 | + | |
| 1212 | + | |
| 1213 | + | |
| 1214 | + | |
| 1215 | + | |
| 1216 | + | |
| 1217 | + | |
| 1218 | + | |
| 1219 | + | |
1205 | 1220 | | |
1206 | 1221 | | |
1207 | 1222 | | |
| |||
1351 | 1366 | | |
1352 | 1367 | | |
1353 | 1368 | | |
| 1369 | + | |
| 1370 | + | |
| 1371 | + | |
| 1372 | + | |
| 1373 | + | |
| 1374 | + | |
| 1375 | + | |
| 1376 | + | |
| 1377 | + | |
| 1378 | + | |
| 1379 | + | |
| 1380 | + | |
| 1381 | + | |
1354 | 1382 | | |
1355 | 1383 | | |
1356 | 1384 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
15 | | - | |
| 15 | + | |
16 | 16 | | |
17 | 17 | | |
18 | 18 | | |
| |||
0 commit comments