]> git.lizzy.rs Git - rust.git/commitdiff
Mention `pub` for structs and fields
authorLeif Arne Storset <leifarne@storset.net>
Sat, 25 Jul 2015 19:05:32 +0000 (21:05 +0200)
committerLeif Arne Storset <leifarne@storset.net>
Sat, 25 Jul 2015 19:20:27 +0000 (21:20 +0200)
src/doc/trpl/crates-and-modules.md

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