@@ -128,7 +128,7 @@ we have a file `hello.rs` containing this program:
128128
129129~~~~
130130fn main() {
131- io::println("hello?");
131+ core:: io::println("hello?");
132132}
133133~~~~
134134
@@ -142,8 +142,8 @@ error. If you introduce an error into the program (for example, by changing
142142an error message like this:
143143
144144~~~~ {.notrust}
145- hello.rs:2:4: 2:16 error: unresolved name: io::print_with_unicorns
146- hello.rs:2 io::print_with_unicorns("hello?");
145+ hello.rs:2:4: 2:16 error: unresolved name: core:: io::print_with_unicorns
146+ hello.rs:2 core:: io::print_with_unicorns("hello?");
147147 ^~~~~~~~~~~~~~~~~~~~~~~
148148~~~~
149149
@@ -180,20 +180,21 @@ JavaScript, C#, or PHP), Rust will feel familiar. Code is arranged
180180in blocks delineated by curly braces; there are control structures
181181for branching and looping, like the familiar ` if ` and ` while ` ; function
182182calls are written ` myfunc(arg1, arg2) ` ; operators are written the same
183- and mostly have the same precedence as in C; comments are again like C.
183+ and mostly have the same precedence as in C; comments are again like C;
184+ module names are separated with double-colon, ` :: ` , as with C++.
184185
185186The main surface difference to be aware of is that the condition at
186187the head of control structures like ` if ` and ` while ` do not require
187188parentheses, while their bodies * must* be wrapped in
188189braces. Single-statement, unbraced bodies are not allowed.
189190
190191~~~~
191- # fn recalibrate_universe () -> bool { true }
192+ # mod universe { fn recalibrate () -> bool { true } }
192193fn main() {
193194 /* A simple loop */
194195 loop {
195196 // A tricky calculation
196- if recalibrate_universe () {
197+ if universe::recalibrate () {
197198 return;
198199 }
199200 }
@@ -209,16 +210,11 @@ let hi = "hi";
209210let mut count = 0;
210211
211212while count < 10 {
212- io::println(hi );
213+ core:: io::println(fmt!("count: %?", i) );
213214 count += 1;
214215}
215216~~~~
216217
217- The name of the function that prints a line of text, ` io::println ` , is
218- qualified: it refers to the function named ` println ` that's defined in the
219- module ` io ` . In Rust, a double colon separates parts of a
220- qualified name. For more details, see the section on [ crates] ( #crates ) .
221-
222218Although Rust can almost always infer the types of local variables, you
223219can specify a variable's type by following it with a colon, then the type
224220name. Constants, an the other hand, always require a type annotation.
0 commit comments