v2 / vlib / v / tests / fn_field_ref_param_struct_init_test.v
22 lines · 19 sloc · 387 bytes · 5d3ad7c0a3127167f0f18478f253c6507a7d012b
Raw
1struct FnFields {
2 by_val fn (int) int = unsafe { nil }
3 by_ref fn (&int) int = unsafe { nil }
4}
5
6fn by_val(n int) int {
7 return n + 1
8}
9
10fn by_ref(n &int) int {
11 return *n + 1
12}
13
14fn test_inline_fn_field_with_ref_param_type_does_not_collide() {
15 fields := FnFields{
16 by_val: by_val
17 by_ref: by_ref
18 }
19 value := 41
20 assert fields.by_val(41) == 42
21 assert fields.by_ref(&value) == 42
22}
23