Skip to content

Commit 95c7f30

Browse files
committed
Mention pub for structs and fields
1 parent e333e6a commit 95c7f30

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

src/doc/trpl/crates-and-modules.md

+4
Original file line numberDiff line numberDiff line change
@@ -355,6 +355,10 @@ Hello in English: Hello!
355355
Goodbye in English: Goodbye.
356356
```
357357
358+
`pub` also applies to `struct`s and their member fields. In keeping with Rust’s
359+
tendency toward safety, simply making a `struct` public won't automatically
360+
make its members public: you must mark the fields individually with `pub`.
361+
358362
Now that our functions are public, we can use them. Great! However, typing out
359363
`phrases::english::greetings::hello()` is very long and repetitive. Rust has
360364
another keyword for importing names into the current scope, so that you can

0 commit comments

Comments
 (0)