Skip to content

Commit

Permalink
Update method.md
Browse files Browse the repository at this point in the history
  • Loading branch information
relaxcn committed Sep 19, 2024
1 parent ef6708a commit 1a478f0
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/basic/method.md
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ fn main() {

因为 `width` 字段是私有的,当用户访问 `rect1.width` 字段时,就会报错。注意在此例中,`Self` 指代的就是被实现方法的结构体 `Rectangle`

特别的是,这种默认的可见性(私有的)可以通过 `pub` 进行覆盖,这样对于模块外部来说,就可以直接访问使用 `pub` 修饰的字段而无需通过访问器。
特别的是,这种默认的可见性(私有的)可以通过 `pub` 进行覆盖,这样对于模块外部来说,就可以直接访问使用 `pub` 修饰的字段而无需通过访问器。这种可见性仅当从定义结构的模块外部访问时才重要,并且具有隐藏信息(封装)的目的。

> ### `->` 运算符到哪去了?
>
Expand Down

0 comments on commit 1a478f0

Please sign in to comment.