vxx / vlib / v2_toberemoved / tests / module_mut_example / state / state.vv2
19 lines · 16 sloc · 233 bytes · c0624b274a458fe3e487d89ae9554c2e8c25bdb6
Raw
1module state
2
3pub struct Counter {
4pub module_mut:
5 value int
6pub mut:
7 label string
8}
9
10pub fn new_counter(label string) Counter {
11 return Counter{
12 label: label
13 }
14}
15
16pub fn (mut c Counter) inc() int {
17 c.value++
18 return c.value
19}
20