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
+
^
515
503
note: in expansion of format_args!
516
504
<std macros>:2:23: 2:77 note: expansion site
517
505
<std macros>:1:1: 3:2 note: in expansion of println!
518
-
src/hello_world.rs:4:5: 4:42 note: expansion site
506
+
src/guessing_game.rs:4:5: 4:42 note: expansion site
519
507
error: aborting due to previous error
520
-
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)
521
509
```
522
510
523
511
Rust will not let us use a value that has not been initialized. So why let us
@@ -1606,45 +1594,41 @@ taken to the screen. Sound good?
1606
1594
1607
1595
## Set up
1608
1596
1609
-
Let's set up a new project. Go to your projects directory. Remember how we
1610
-
had to create our directory structure and a `Cargo.toml` for `hello_world`? Cargo
1611
-
has a command that does that for us. Let's give it a shot:
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:
1612
1599
1613
1600
```{bash}
1614
1601
$ cd ~/projects
1615
-
$ cargo new guessing_game --bin
1602
+
$ mkdir guessing_game
1616
1603
$ cd guessing_game
1604
+
$ mkdir src
1617
1605
```
1618
1606
1619
-
We pass the name of our project to `cargo new`, and then the `--bin` flag,
1620
-
since we're making a binary, rather than a library.
1621
-
1622
-
Check out the generated `Cargo.toml`:
1607
+
Great. Next, let's make a `Cargo.toml` file so Cargo knows how to build our
1608
+
project:
1623
1609
1624
1610
```{ignore}
1625
1611
[package]
1626
1612
1627
1613
name = "guessing_game"
1628
1614
version = "0.1.0"
1629
-
authors = ["Your Name <you@example.com>"]
1615
+
authors = [ "someone@example.com" ]
1630
1616
1631
1617
[[bin]]
1632
1618
1633
1619
name = "guessing_game"
1634
1620
```
1635
1621
1636
-
Cargo gets this information from your environment. If it's not correct, go ahead
1637
-
and fix that.
1638
-
1639
-
Finally, Cargo generated a hello, world for us. Check out `src/main.rs`:
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`:
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)
@@ -2501,7 +2486,27 @@ Enough talk, let's build something! Let's make a new project called `modules`.
2501
2486
2502
2487
```{bash,ignore}
2503
2488
$ cd ~/projects
2504
-
$ cargo new modules --bin
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