Skip to content

Commit 9c8c82b

Browse files
committed
hello_world.rs -> main.rs
1 parent b85191a commit 9c8c82b

File tree

1 file changed

+19
-18
lines changed

1 file changed

+19
-18
lines changed

src/doc/guide.md

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -139,14 +139,15 @@ the documentation for your shell for more details.
139139

140140
Let's make a new source file next. I'm going to use the syntax `editor
141141
filename` to represent editing a file in these examples, but you should use
142-
whatever method you want. We'll call our file `hello_world.rs`:
142+
whatever method you want. We'll call our file `main.rs`:
143143

144144
```{bash}
145-
$ editor hello_world.rs
145+
$ editor main.rs
146146
```
147147

148148
Rust files always end in a `.rs` extension. If you're using more than one word
149-
in your file name, use an underscore. `hello_world.rs` versus `goodbye.rs`.
149+
in your file name, use an underscore. `hello_world.rs` rather than
150+
`helloworld.rs`.
150151

151152
Now that you've got your file open, type this in:
152153

@@ -159,7 +160,7 @@ fn main() {
159160
Save the file, and then type this into your terminal window:
160161

161162
```{bash}
162-
$ rustc hello_world.rs
163+
$ rustc main.rs
163164
$ ./hello_world # or hello_world.exe on Windows
164165
Hello, world!
165166
```
@@ -221,22 +222,22 @@ Finally, actually **compiling** and **running** our program. We can compile
221222
with our compiler, `rustc`, by passing it the name of our source file:
222223

223224
```{bash}
224-
$ rustc hello_world.rs
225+
$ rustc main.rs
225226
```
226227

227228
This is similar to `gcc` or `clang`, if you come from a C or C++ background. Rust
228229
will output a binary executable. You can see it with `ls`:
229230

230231
```{bash}
231232
$ ls
232-
hello_world hello_world.rs
233+
main main.rs
233234
```
234235

235236
Or on Windows:
236237

237238
```{bash}
238239
$ dir
239-
hello_world.exe hello_world.rs
240+
main.exe main.rs
240241
```
241242

242243
There are now two files: our source code, with the `.rs` extension, and the
@@ -293,7 +294,7 @@ do that part first:
293294

294295
```{bash}
295296
$ mkdir src
296-
$ mv hello_world.rs src/hello_world.rs
297+
$ mv main.rs src/main.rs
297298
```
298299

299300
Cargo expects your source files to live inside a `src` directory. That leaves
@@ -461,9 +462,9 @@ let x;
461462
...we'll get an error:
462463

463464
```{ignore}
464-
src/hello_world.rs:2:9: 2:10 error: cannot determine a type for this local variable: unconstrained type
465-
src/hello_world.rs:2 let x;
466-
^
465+
src/main.rs:2:9: 2:10 error: cannot determine a type for this local variable: unconstrained type
466+
src/main.rs:2 let x;
467+
^
467468
```
468469

469470
Giving it a type will compile, though:
@@ -472,7 +473,7 @@ Giving it a type will compile, though:
472473
let x: int;
473474
```
474475

475-
Let's try it out. Change your `src/hello_world.rs` file to look like this:
476+
Let's try it out. Change your `src/main.rs` file to look like this:
476477

477478
```{rust}
478479
fn main() {
@@ -487,8 +488,8 @@ but it will still print "Hello, world!":
487488

488489
```{ignore,notrust}
489490
Compiling hello_world v0.0.1 (file:///home/you/projects/hello_world)
490-
src/hello_world.rs:2:9: 2:10 warning: unused variable: `x`, #[warn(unused_variable)] on by default
491-
src/hello_world.rs:2 let x: int;
491+
src/main.rs:2:9: 2:10 warning: unused variable: `x`, #[warn(unused_variable)] on by default
492+
src/main.rs:2 let x: int;
492493
^
493494
```
494495

@@ -509,13 +510,13 @@ And try to build it. You'll get an error:
509510
```{bash}
510511
$ cargo build
511512
Compiling hello_world v0.0.1 (file:///home/you/projects/hello_world)
512-
src/hello_world.rs:4:39: 4:40 error: use of possibly uninitialized variable: `x`
513-
src/hello_world.rs:4 println!("The value of x is: {}", x);
514-
^
513+
src/main.rs:4:39: 4:40 error: use of possibly uninitialized variable: `x`
514+
src/main.rs:4 println!("The value of x is: {}", x);
515+
^
515516
note: in expansion of format_args!
516517
<std macros>:2:23: 2:77 note: expansion site
517518
<std macros>:1:1: 3:2 note: in expansion of println!
518-
src/hello_world.rs:4:5: 4:42 note: expansion site
519+
src/main.rs:4:5: 4:42 note: expansion site
519520
error: aborting due to previous error
520521
Could not compile `hello_world`.
521522
```

0 commit comments

Comments
 (0)