struct User {
email string // private and immutable (default)
}
您可以将它们定义为private mutable。
struct User {
email string
mut:
first_name string // private mutable
last_name string // (you can list multiple fields with the same access modifier)
}
您还可以将它们定义为public immutable(只读)。
struct User {
email string
mut:
first_name string
last_name string
pub:
sin_number int // public immutable (readonly)
}
或作为public,但仅在父模块中是mutable。
struct User {
email string
mut:
first_name string
last_name string
pub:
sin_number int
pub mut:
phone int // public, but mutable only in parent module
}
或父模块内外的public和mutable。
struct User {
email string
mut:
first_name string
last_name string
pub:
sin_number int
pub mut:
phone int
__global:
address_1 string // public and mutable both inside and outside parent module
address_2 string // (not recommended to use, that's why the 'global' keyword
city string // starts with __)
country string
zip string
}