~mna/snow

snow/pkg/codegen/testdata/struct_multi_fields_per_decl.snow.want -rw-r--r-- 1018 bytes
424066c5Martin Angers doc: v0.0.5 1 year, 7 months ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
package main

import "fmt"

type _اSا0 struct {
	_اp1    string
	_اp2    string
	_اcount int
}

func _اSا0اnew(
	s _اSا0,
	m map[string]bool,
) _اSا0 {
	var r _اSا0
	if m["p1"] {
		r._اp1 = s._اp1
	}
	if m["p2"] {
		r._اp2 = s._اp2
	}
	if m["count"] {
		r._اcount = s._اcount
	}
	return r
}

type _اSا1 struct {
	_اp1    int
	_اp2    int
	_اcount int
}

func _اSا1اnew(
	s _اSا1,
	m map[string]bool,
) _اSا1 {
	var r _اSا1
	if m["p1"] {
		r._اp1 = s._اp1
	}
	if m["p2"] {
		r._اp2 = s._اp2
	}
	if m["count"] {
		r._اcount = s._اcount
	}
	return r
}

func _اprintlnا0(
	v _اSا0,
) {
	fmt.Println(v)
}

func _اprintlnا1(
	v _اSا1,
) {
	fmt.Println(v)
}

func main() {
	var s _اSا0
	var i _اSا1
	s = _اSا0اnew(_اSا0{_اp1: "a", _اp2: "b", _اcount: 1}, map[string]bool{"p1": true, "p2": true, "count": true})
	i = _اSا1اnew(_اSا1{_اp1: 1, _اp2: 2, _اcount: 2}, map[string]bool{"p1": true, "p2": true, "count": true})
	_اprintlnا0(s)
	_اprintlnا1(i)
}