| 1 | pub struct Test2 { |
| 2 | a int |
| 3 | } |
| 4 | |
| 5 | pub struct Test { |
| 6 | a Test2 |
| 7 | b ?string |
| 8 | c ?Test2 |
| 9 | d ?&Test2 |
| 10 | } |
| 11 | |
| 12 | @[manualfree] |
| 13 | fn test_main() { |
| 14 | t := Test{ |
| 15 | b: 'b' |
| 16 | } |
| 17 | |
| 18 | println('t: ${t}') |
| 19 | |
| 20 | defer { |
| 21 | unsafe { |
| 22 | t.free() |
| 23 | } |
| 24 | } |
| 25 | |
| 26 | mut t2 := ?Test(Test{ |
| 27 | b: 'b' |
| 28 | }) |
| 29 | println('t: ${t2}') |
| 30 | |
| 31 | defer { |
| 32 | unsafe { |
| 33 | if t2 != none { |
| 34 | t2.free() |
| 35 | } |
| 36 | } |
| 37 | } |
| 38 | } |
| 39 |