<commit_before>% Cargo, Rust's Package Manager

# Installing

The easiest way to get Cargo is to get the Rust nightly build by using
the `rustup` script:

```shell
$ curl -sS https://static.rust-lang.org/rustup.sh | sudo bash
```

This will get you the latest Rust nightly for your platform along with
the latest Cargo. You should run this script almost every day to get the latest updates.

If you are on Windows, you can directly download the latest 32bit ([Rust](https://static.rust-lang.org/dist/rust-nightly-i686-pc-windows-gnu.exe)
and [Cargo](https://static.rust-lang.org/cargo-dist/cargo-nightly-i686-pc-windows-gnu.tar.gz)) or 64bit ([Rust](https://static.rust-lang.org/dist/rust-nightly-x86_64-pc-windows-gnu.exe) and [Cargo](https://static.rust-lang.org/cargo-dist/cargo-nightly-x86_64-pc-windows-gnu.tar.gz)) nightlies.

Alternatively, you can build Cargo from source.

# Let's Get Started

To start a new project with Cargo, use `cargo new`:

```shell
$ cargo new hello_world --bin
```

We're passing `--bin` because we're making a binary program: if we
were making a library, we'd leave it off.

Let's check out what Cargo has generated for us:

```shell
$ cd hello_world
$ tree .
.
├── Cargo.toml
└── src
    └── main.rs

1 directory, 2 files
```

This is all we need to get started. First, let's check out `Cargo.toml`:

```toml
[package]
name = "hello_world"
version = "0.0.1"
authors = ["<NAME> <<EMAIL>>"]
```

This is called a **manifest**, and it contains all of the metadata that Cargo
needs to compile your project.

Here's what's in `src/main.rs`:

```
fn main() {
    println!("Hello, world!");
}
```

Cargo generated a 'hello world' for us. Let's compile it:

<pre><code class="language-shell">$ cargo build
<span style="font-weight: bold"
class="s1">   Compiling</span> hello_world v0.0.1 (file:///path/to/project/hello_world)</code></pre>

And then run it:

```shell
$ ./target/hello_world
Hello, world!
```

We can also use `cargo run` to compile and then run it, all in one step:

<pre><code class="language-shell">$ cargo run
<span style="font-weight: bold"
class="s1">     Fresh</span> hello_world v0.0.1 (file:///path/to/project/hello_world)<commit_msg>Auto merge of #1482 - DavidAwad:patch-1, r=alexcrichton<commit_after>% Cargo, Rust's Package Manager

# Installing

The easiest way to get Cargo is to get the Rust nightly build by using
the `rustup` script:

```shell
$ curl -sS https://static.rust-lang.org/rustup.sh | sudo bash
```

This will get you the latest Rust nightly for your platform along with
the latest Cargo. You should run this script almost every day to get the latest updates.

If you are on Windows, you can directly download the latest 32bit ([Rust](https://static.rust-lang.org/dist/rust-nightly-i686-pc-windows-gnu.exe)
and [Cargo](https://static.rust-lang.org/cargo-dist/cargo-nightly-i686-pc-windows-gnu.tar.gz)) or 64bit ([Rust](https://static.rust-lang.org/dist/rust-nightly-x86_64-pc-windows-gnu.exe) and [Cargo](https://static.rust-lang.org/cargo-dist/cargo-nightly-x86_64-pc-windows-gnu.tar.gz)) nightlies.

Alternatively, you can build Cargo from source.

# Let's Get Started

To start a new project with Cargo, use `cargo new`:

```shell
$ cargo new hello_world --bin
```

We're passing `--bin` because we're making a binary program: if we
were making a library, we'd leave it off.

Let's check out what Cargo has generated for us:

```shell
$ cd hello_world
$ tree .
.
├── Cargo.toml
└── src
    └── main.rs

1 directory, 2 files
```

This is all we need to get started. First, let's check out `Cargo.toml`:

```toml
[package]
name = "hello_world"
version = "0.0.1"
authors = ["<NAME> <<EMAIL>>"]
```

This is called a **manifest**, and it contains all of the metadata that Cargo
needs to compile your project.

Here's what's in `src/main.rs`:

```
fn main() {
    println!("Hello, world!");
}
```

Cargo generated a 'hello world' for us. Let's compile it:

<pre><code class="language-shell">$ cargo build
<span style="font-weight: bold"
class="s1">   Compiling</span> hello_world v0.0.1 (file:///path/to/project/hello_world)</code></pre>

And then run it:

```shell
$ ./target/debug/hello_world
Hello, world!
```

We can also use `cargo run` to compile and then run it, all in one step:

<pre><code class="language-shell">$ cargo run
<span style="font-weight: bold"
class="s1">     Fresh</span> hello_world v0.0.1 (file:///path/to/project/hello_world)
{'fraction_non_alphanumeric': 0.14683257918552037, 'fraction_numerical': 0.015158371040723982, 'mean_word_length': 4.140697674418605, 'pattern_counts': {'":': 0, '<': 29, '<?xml version=': 0, '>': 29, 'https://': 10, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3551555', 'n_tokens_mistral': 1620, 'n_tokens_neox': 1509, 'n_words': 512}