From 95c7f306c7c57f028d7e577ef13a5fc66f3086eb Mon Sep 17 00:00:00 2001 From: Leif Arne Storset Date: Sat, 25 Jul 2015 21:05:32 +0200 Subject: [PATCH] Mention `pub` for structs and fields --- src/doc/trpl/crates-and-modules.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/doc/trpl/crates-and-modules.md b/src/doc/trpl/crates-and-modules.md index 63fdef0760feb..bc2c827ca34f3 100644 --- a/src/doc/trpl/crates-and-modules.md +++ b/src/doc/trpl/crates-and-modules.md @@ -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