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/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
+
^
503
515
note: in expansion of format_args!
504
516
<std macros>:2:23: 2:77 note: expansion site
505
517
<std macros>:1:1: 3:2 note: in expansion of println!
506
-
src/guessing_game.rs:4:5: 4:42 note: expansion site
518
+
src/hello_world.rs:4:5: 4:42 note: expansion site
507
519
error: aborting due to previous error
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)
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)
509
521
```
510
522
511
523
Rust will not let us use a value that has not been initialized. So why let us
@@ -1594,41 +1606,45 @@ taken to the screen. Sound good?
1594
1606
1595
1607
## Set up
1596
1608
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:
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:
1599
1612
1600
1613
```{bash}
1601
1614
$ cd ~/projects
1602
-
$ mkdir guessing_game
1615
+
$ cargo new guessing_game --bin
1603
1616
$ cd guessing_game
1604
-
$ mkdir src
1605
1617
```
1606
1618
1607
-
Great. Next, let's make a `Cargo.toml` file so Cargo knows how to build our
1608
-
project:
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`:
1609
1623
1610
1624
```{ignore}
1611
1625
[package]
1612
1626
1613
1627
name = "guessing_game"
1614
1628
version = "0.1.0"
1615
-
authors = [ "someone@example.com" ]
1629
+
authors = ["Your Name <you@example.com>"]
1616
1630
1617
1631
[[bin]]
1618
1632
1619
1633
name = "guessing_game"
1620
1634
```
1621
1635
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`:
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`:
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 +2501,7 @@ Enough talk, let's build something! Let's make a new project called `modules`.
2486
2501
2487
2502
```{bash,ignore}
2488
2503
$ 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