From dc83e30a4417af4d0efd53b29969f9e19650b836 Mon Sep 17 00:00:00 2001 From: Alexander Medvednikov Date: Fri, 13 Dec 2019 20:09:11 +0300 Subject: [PATCH] access modifiers: update tests/examples --- vlib/compiler/tests/struct_test.v | 13 +++++++++++++ vlib/encoding/csv/reader.v | 3 +-- vlib/log/log.v | 3 +-- vlib/net/urllib/urllib.v | 2 +- vlib/net/urllib/values.v | 6 ++---- 5 files changed, 18 insertions(+), 9 deletions(-) diff --git a/vlib/compiler/tests/struct_test.v b/vlib/compiler/tests/struct_test.v index 0086d5567a..f0931b7471 100644 --- a/vlib/compiler/tests/struct_test.v +++ b/vlib/compiler/tests/struct_test.v @@ -154,6 +154,19 @@ fn test_assoc_with_constants() { assert again.b == 22 } +struct AttrTest{ + a int // private immutable (default) +mut: + b int // private mutable + c int // (you can list multiple fields with the same access modifier) +pub: + d int // public immmutable (readonly) +pub mut: + e int // public, but mutable only in parent module +//__global: + f int // public and mutable both inside and outside parent module +} + /* [typedef] struct C.fixed { diff --git a/vlib/encoding/csv/reader.v b/vlib/encoding/csv/reader.v index e8c9ce863b..a1a4b81e3a 100644 --- a/vlib/encoding/csv/reader.v +++ b/vlib/encoding/csv/reader.v @@ -21,8 +21,7 @@ struct Reader { // has_header bool // headings []string data string -pub: -mut: +pub mut: delimiter byte comment byte is_mac_pre_osx_le bool diff --git a/vlib/log/log.v b/vlib/log/log.v index 6c85409318..365b643ca5 100644 --- a/vlib/log/log.v +++ b/vlib/log/log.v @@ -44,10 +44,9 @@ pub struct Log { mut: level LogLevel output_label string - ofile os.File output_to_file bool -pub: +pub mut: output_file_name string } diff --git a/vlib/net/urllib/urllib.v b/vlib/net/urllib/urllib.v index 5f6c262435..ebcc011717 100644 --- a/vlib/net/urllib/urllib.v +++ b/vlib/net/urllib/urllib.v @@ -321,7 +321,7 @@ fn escape(s string, mode EncodingMode) string { // URL's String method uses the escaped_path method to obtain the path. See the // escaped_path method for more details. pub struct URL { -pub: mut: +pub mut: scheme string opaque string // encoded opaque data user &Userinfo // username and password information diff --git a/vlib/net/urllib/values.v b/vlib/net/urllib/values.v index cf83280b64..49c66dc735 100644 --- a/vlib/net/urllib/values.v +++ b/vlib/net/urllib/values.v @@ -5,14 +5,12 @@ module urllib struct Value { -pub: -mut: +pub mut: data []string } struct Values { -pub: -mut: +pub mut: data map[string]Value size int }