4

What is the difference between cargo new <project_name> --bin and cargo new <project_name>?

It seems both commands make exactly the same project; all components are consistent.

I think --bin stands for "binary", but I don't know when to use this option or not.

Shepmaster
  • 388,571
  • 95
  • 1,107
  • 1,366
kwklly
  • 79
  • 3

1 Answers1

8

There is no difference between cargo new and cargo new --bin. From First Steps with Cargo, emphasis mine:

To start a new package with Cargo, use cargo new:

$ cargo new hello_world

Cargo defaults to --bin to make a binary program. To make a library, we would pass --lib, instead.

Likewise, Cargo's command line help tells you the same thing. From cargo new --help, with some irrelevant lines removed:

% cargo new --help
OPTIONS:
        --bin                      Use a binary (application) template [default]
        --lib                      Use a library template

See also

Shepmaster
  • 388,571
  • 95
  • 1,107
  • 1,366