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
Cargo expects your source files to live inside a `src` directory. That leaves
45
-
the top level for other things, like READMEs, license information, and anything
46
-
not related to your code. Cargo helps us keep our projects nice and tidy. A
47
-
place for everything, and everything in its place.
45
+
Cargo expects our source files to live inside a `src` directory. That leaves the
46
+
top level for other things, like READMEs, license information, and anything not
47
+
related to our code. Cargo helps us keep our projects nice and tidy. A place for
48
+
everything, and everything in its place.
48
49
49
50
Next, our configuration file:
50
51
51
52
```bash
52
-
$ editor Cargo.toml
53
+
$ editor Cargo.toml# or 'notepad Cargo.toml' on Windows
53
54
```
54
55
55
-
Make sure to get this name right: you need the capital `C`!
56
+
Make sure to get this name right: we need the capital `C`!
56
57
57
58
Put this inside:
58
59
@@ -109,8 +110,8 @@ about the future: when our project gets more complex, we need to do more
109
110
things to get all of the parts to properly compile. With Cargo, as our project
110
111
grows, we can just run `cargo build`, and it’ll work the right way.
111
112
112
-
When your project is finally ready for release, you can use
113
-
`cargo build --release` to compile your project with optimizations.
113
+
When our project is finally ready for release, we can use `cargo build
114
+
--release` to compile our project with optimizations.
114
115
115
116
You'll also notice that Cargo has created a new file: `Cargo.lock`.
116
117
@@ -120,14 +121,14 @@ name = "hello_world"
120
121
version = "0.0.1"
121
122
```
122
123
123
-
The `Cargo.lock` file is used by Cargo to keep track of dependencies in your application.
124
-
Right now, we don’t have any, so it’s a bit sparse. You won't ever need
125
-
to touch this file yourself, just let Cargo handle it.
124
+
The `Cargo.lock` file is used by Cargo to keep track of dependencies in our
125
+
application. Right now, we don’t have any, so it’s a bit sparse. We won't ever
126
+
need to touch this file ourselves, just let Cargo handle it.
126
127
127
128
That’s it! We’ve successfully built `hello_world` with Cargo. Even though our
128
-
program is simple, it’s using much of the real tooling that you’ll use for the
129
-
rest of your Rust career. You can expect to do this to get started with
130
-
virtually all Rust projects:
129
+
program is simple, it’s using much of the real tooling that we’ll use for the
130
+
rest of our Rust career. We can expect to do this to get started with virtually
131
+
all Rust projects:
131
132
132
133
```bash
133
134
$ git clone someurl.com/foo
@@ -137,17 +138,19 @@ $ cargo build
137
138
138
139
## A New Project
139
140
140
-
You don’t have to go through this whole process every time you want to start a
141
-
new project! Cargo has the ability to make a bare-bones project directory in
142
-
which you can start developing right away.
141
+
We don’t have to go through this whole process every time we want to start a new
142
+
project! Cargo has the ability to make a bare-bones project directory in which
143
+
we can start developing right away.
143
144
144
-
To start a new project with Cargo, use `cargo new`:
145
+
To start a new project with Cargo, we use `cargo new`:
145
146
146
147
```bash
147
148
$ cargo new hello_world --bin
148
149
```
149
150
150
-
We’re passing `--bin` because our goal is to get straight to making an executable application, as opposed to a library. Executables are often called ‘binaries.’ (as in `/usr/bin`, if you’re on a Unix system)
151
+
We’re passing `--bin` because our goal is to get straight to making an
152
+
executable application, as opposed to a library. Executables are often called
153
+
‘binaries.’ (as in `/usr/bin`, if we’re on a Unix system)
151
154
152
155
Let's check out what Cargo has generated for us:
153
156
@@ -162,7 +165,7 @@ $ tree .
162
165
1 directory, 2 files
163
166
```
164
167
165
-
If you don't have the `tree` command, you can probably get it from your
168
+
If we don't have the `tree` command, we can probably get it from our
166
169
distribution’s package manager. It’s not necessary, but it’s certainly useful.
167
170
168
171
This is all we need to get started. First, let’s check out `Cargo.toml`:
0 commit comments