9

While reading the official book, I stumbled upon packages and crates. To create a new "project", this is what I ran:

$ cargo new my-project
     Created binary (application) `my-project` package
$ ls my-project
Cargo.toml
src
$ ls my-project/src
main.rs

The book states the following:

A package must contain zero or one library crates, and no more. It can contain as many binary crates as you’d like, but it must contain at least one crate (either library or binary).

My doubt is, what is the difference between binary crates and normal crates?

Aviral Srivastava
  • 4,058
  • 8
  • 29
  • 81

1 Answers1

15

The difference is between binary crate and library crate. There are no "normal" crates.

  • A binary crate is an executable program.

  • A library crate is a library of reusable components that can be included in another library crate or in a binary crate.

mcarton
  • 27,633
  • 5
  • 85
  • 95