0 branches
Tree
Top files
Clone with HTTPS:
Module Mutable Fields Example
This is a V2 fixture for pub module_mut: struct fields.
It demonstrates a field that is public for reading, but mutable only from the
module that declares the struct. A separate pub mut: field is included to show
the difference with a publicly mutable field.
The sources are stored as .vv2 so shared V1/vfmt paths do not parse V2-only
syntax directly. To try it manually, copy the files to temporary .v files and
compile them with -v2.
Expected behavior:
counter.valuecan be read frommain;counter.valueis changed throughstate.Counter.inc(), inside modulestate;counter.labelcan be changed frommainbecause it is underpub mut:;- direct external mutation like
counter.value++must be rejected.