简体   繁体   English

我什么时候应该为新货物使用 --bin 选项?

[英]When should I use the --bin option for cargo new?

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

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.我认为--bin代表“二进制”,但我不知道何时使用此选项。

There is no difference between cargo new and cargo new --bin . cargo newcargo new --bin之间没有区别。 From First Steps with Cargo , emphasis mine:货物的第一步开始,强调我的:

To start a new package with Cargo, use cargo new :要使用 Cargo 开始一个新包,请使用cargo new

 $ cargo new hello_world

Cargo defaults to --bin to make a binary program . Cargo 默认为--bin以制作二进制程序 To make a library, we would pass --lib , instead.为了创建一个库,我们将传递--lib ,而不是。

Likewise, Cargo's command line help tells you the same thing.同样,Cargo 的命令行帮助告诉你同样的事情。 From cargo new --help , with some irrelevant lines removed:cargo new --help删除了一些不相关的行:

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

See also也可以看看

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM