Skip to content

Commit

Permalink
Rollup merge of rust-lang#27397 - Dangthrimble:master, r=steveklabnik
Browse files Browse the repository at this point in the history
Clarifications for those new to Rust and Cargo:
* It's a good idea to get rid of the original `main.exe` in project root
* Slight clarification on the use of `main.rs` vs `lib.rs`
* Clarify that the TOML file needs to be in project root
  • Loading branch information
Manishearth committed Aug 4, 2015
2 parents f971f86 + c54df0e commit 3e3a9b4
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 19 deletions.
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

0 comments on commit 3e3a9b4

Please sign in to comment.