Skip to content

Clarifications for Hello, Cargo! #27397

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Aug 4, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/doc/trpl/guessing-game.md
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,8 @@ use std::io;

We’ll need to take user input, and then print the result as output. As such, we
need the `io` library from the standard library. Rust only imports a few things
into every program, [the ‘prelude’][prelude]. If it’s not in the prelude,
you’ll have to `use` it directly.
by default into every program, [the ‘prelude’][prelude]. If it’s not in the
prelude, you’ll have to `use` it directly.

[prelude]: ../std/prelude/index.html

Expand Down
36 changes: 19 additions & 17 deletions src/doc/trpl/hello-cargo.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@ so it is assumed that Rust projects will use Cargo from the beginning.
[cratesio]: http://doc.crates.io

Cargo manages three things: building your code, downloading the dependencies
your code needs, and building those dependencies. At first, your
program doesn’t have any dependencies, so we’ll only be using the first part of
its functionality. Eventually, we’ll add more. Since we started off by using
Cargo, it'll be easy to add later.
your code needs, and building those dependencies. At first, your program doesn’t
have any dependencies, so we’ll only be using the first part of its
functionality. Eventually, we’ll add more. Since we started off by using Cargo,
it'll be easy to add later.

If you installed Rust via the official installers you will also have Cargo. If
you installed Rust some other way, you may want to [check the Cargo
If we installed Rust via the official installers we will also have Cargo. If we
installed Rust some other way, we may want to [check the Cargo
README][cargoreadme] for specific instructions about installing it.

[cargoreadme]: https://github.com/rust-lang/cargo#installing-cargo-from-nightlies
Expand All @@ -23,20 +23,21 @@ README][cargoreadme] for specific instructions about installing it.

Let’s convert Hello World to Cargo.

To Cargo-ify our project, we need to do two things: Make a `Cargo.toml`
configuration file, and put our source file in the right place. Let's
do that part first:
To Cargo-ify our project, we need to do three things: Make a `Cargo.toml`
configuration file, put our source file in the right place, and get rid of the
old executable (`main.exe` on Windows, `main` everywhere else). Let's do that part first:

```bash
$ mkdir src
$ mv main.rs src/main.rs
$ rm main # or main.exe on Windows
```

Note that since we're creating an executable, we used `main.rs`. If we
want to make a library instead, we should use `lib.rs`. This convention is required
for Cargo to successfully compile our projects, but it can be overridden if we wish.
Custom file locations for the entry point can be specified
with a [`[lib]` or `[[bin]]`][crates-custom] key in the TOML file.
Note that since we're creating an executable, we retain `main.rs` as the source
filename. If we want to make a library instead, we should use `lib.rs`. This
convention is used by Cargo to successfully compile our projects, but it can be
overridden if we wish. Custom file locations for the entry point can be
specified with a [`[lib]` or `[[bin]]`][crates-custom] key in the TOML file.

[crates-custom]: http://doc.crates.io/manifest.html#configuring-a-target

Expand All @@ -63,8 +64,8 @@ version = "0.0.1"
authors = [ "Your name <[email protected]>" ]
```

This file is in the [TOML][toml] format. TOML is similar to INI, but has some
extra goodies. According to the TOML docs,
This file is in the [TOML][toml] format. TOML is similar to INI, but has some
extra goodies. According to the TOML docs,

> TOML aims to be a minimal configuration file format that's easy to read due
> to obvious semantics. TOML is designed to map unambiguously to a hash table.
Expand All @@ -73,7 +74,8 @@ extra goodies. According to the TOML docs,

[toml]: https://github.com/toml-lang/toml

Once you have this file in place, we should be ready to build! To do so, run:
Once we have this file in place in our project's root directory, we should be
ready to build! To do so, run:

```bash
$ cargo build
Expand Down