You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
src/guessing_game.rs:4:39: 4:40 error: use of possibly uninitialized variable: `x`
501
+
src/guessing_game.rs:4 println!("The value of x is: {}", x);
502
+
^
503
503
note: in expansion of format_args!
504
504
<std macros>:2:23: 2:77 note: expansion site
505
505
<std macros>:1:1: 3:2 note: in expansion of println!
506
-
src/hello_world.rs:4:5: 4:42 note: expansion site
506
+
src/guessing_game.rs:4:5: 4:42 note: expansion site
507
507
error: aborting due to previous error
508
-
Could not execute process `rustc src/hello_world.rs --crate-type bin --out-dir /home/you/projects/hello_world/target -L /home/you/projects/hello_world/target -L /home/you/projects/hello_world/target/deps` (status=101)
508
+
Could not execute process `rustc src/guessing_game.rs --crate-type bin --out-dir /home/you/projects/guessing_game/target -L /home/you/projects/guessing_game/target -L /home/you/projects/guessing_game/target/deps` (status=101)
509
509
```
510
510
511
511
Rust will not let us use a value that has not been initialized. So why let us
@@ -1594,41 +1594,45 @@ taken to the screen. Sound good?
1594
1594
1595
1595
## Set up
1596
1596
1597
-
Let's set up a new project. Go to your projects directory, and make a new
1598
-
directory for the project, as well as a `src` directory for our code:
1597
+
Let's set up a new project. Go to your projects directory. Remember how we
1598
+
had to create our directory structure and a `Cargo.toml` for `hello_world`? Cargo
1599
+
has a command that does that for us. Let's give it a shot:
1599
1600
1600
1601
```{bash}
1601
1602
$ cd ~/projects
1602
-
$ mkdir guessing_game
1603
+
$ cargo new guessing_game --bin
1603
1604
$ cd guessing_game
1604
-
$ mkdir src
1605
1605
```
1606
1606
1607
-
Great. Next, let's make a `Cargo.toml` file so Cargo knows how to build our
1608
-
project:
1607
+
We pass the name of our project to `cargo new`, and then the `--bin` flag,
1608
+
since we're making a binary, rather than a library.
1609
+
1610
+
Check out the generated `Cargo.toml`:
1609
1611
1610
1612
```{ignore}
1611
1613
[package]
1612
1614
1613
1615
name = "guessing_game"
1614
1616
version = "0.1.0"
1615
-
authors = [ "someone@example.com" ]
1617
+
authors = ["Your Name <you@example.com>"]
1616
1618
1617
1619
[[bin]]
1618
1620
1619
1621
name = "guessing_game"
1620
1622
```
1621
1623
1622
-
Finally, we need our source file. Let's just make it hello world for now, so we
1623
-
can check that our setup works. In `src/guessing_game.rs`:
1624
+
Cargo gets this information from your environment. If it's not correct, go ahead
1625
+
and fix that.
1626
+
1627
+
Finally, Cargo generated a hello, world for us. Check out `src/main.rs`:
src/guessing_game.rs:20:15: 20:20 error: mismatched types: expected `int` but found `collections::string::String` (expected int but found struct collections::string::String)
@@ -2486,27 +2489,7 @@ Enough talk, let's build something! Let's make a new project called `modules`.
2486
2489
2487
2490
```{bash,ignore}
2488
2491
$ cd ~/projects
2489
-
$ mkdir modules
2490
-
$ cd modules
2491
-
$ mkdir src
2492
-
```
2493
-
2494
-
We need to make our two 'hello world' files. In `src/main.rs`:
0 commit comments