v / vlib / v2 / tests / module_mut_example / state / state.vv2
19 lines · 16 sloc · 233 bytes · 20eada7233525573d6471d2cc70fa501213e430a
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