| 1 | struct Window { |
| 2 | mut: |
| 3 | calls int |
| 4 | on_init fn (mut w main.Window) = unsafe { nil } |
| 5 | cb fn (mut w main.Window, x int) = unsafe { nil } |
| 6 | } |
| 7 | |
| 8 | fn (mut w Window) run() { |
| 9 | w.on_init(mut w) |
| 10 | w.cb(mut w, w.calls) |
| 11 | } |
| 12 | |
| 13 | fn (mut w Window) method_with_mut_receiver() { |
| 14 | w.calls++ |
| 15 | } |
| 16 | |
| 17 | fn test_mut_lambda_expr() { |
| 18 | mut window := Window{ |
| 19 | on_init: |mut w| w.method_with_mut_receiver() |
| 20 | cb: |mut w, mut y| unsafe { |
| 21 | if true { |
| 22 | assert y == 1 |
| 23 | w.calls++ |
| 24 | } |
| 25 | } |
| 26 | } |
| 27 | window.run() |
| 28 | assert window.calls == 2 |
| 29 | } |
| 30 | |