Skip to content

Conversation

@relaxcn
Copy link
Contributor

@relaxcn relaxcn commented Sep 19, 2024

修改关于结构体可见性的说明和代码示例。具体参考 :

  1. https://doc.rust-lang.org/rust-by-example/mod/struct_visibility.html
  2. https://stackoverflow.com/questions/44865842/is-it-possible-to-make-a-private-variable-in-rust

之前的代码中,即使不使用访问器,而是直接访问结构体字段,程序也可以正常运行。

这是因为可见性仅在从定义结构体的外部访问时才有意义。

Copy link
Owner

@sunface sunface left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

有理有据,思路清晰,很棒!

@sunface sunface merged commit 1eaa762 into sunface:main Oct 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants