Skip to content

Commit

Permalink
Initialize a new Cargo package
Browse files Browse the repository at this point in the history
```shell
cargo init
```

By default cargo initializes a new package containing a *binary* crate.
The file that gets compiled into the binary is located at
`src/main.rs`. This is by convention and we can specify different paths
and names for binaries.

We also get a `Cargo.lock` and a `Cargo.toml`. These are similar to
JavaScript's `package.json` and `package-lock.json` or `yarn.lock`.
The `Cargo.toml` defines different features of our package including
`dependencies`, defining zero or one library crates, and defining as
many binary crates as we want.

We can run the new binary with `cargo run`.

```shell
❯ cargo run
   Compiling digital-garden-steps v0.1.0 (/digital-garden-steps)
    Finished dev [unoptimized + debuginfo] target(s) in 1.38s
     Running `target/debug/digital-garden-steps`
Hello, world!
```
  • Loading branch information
ChristopherBiscardi committed Dec 29, 2020
1 parent e649acb commit e6f08a3
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .gitignore
@@ -1 +1 @@
/target
/target
5 changes: 5 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions Cargo.toml
@@ -0,0 +1,9 @@
[package]
name = "digital-garden-steps"
version = "0.1.0"
authors = ["Christopher Biscardi <chris@christopherbiscardi.com>"]
edition = "2018"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
3 changes: 3 additions & 0 deletions src/main.rs
@@ -0,0 +1,3 @@
fn main() {
println!("Hello, world!");
}

0 comments on commit e6f08a3

Please sign in to comment.