本文介绍了Rust 中的库 crate 和普通 crate 有什么区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在阅读官方书籍时,我偶然发现了包裹和板条箱.要创建一个新的项目",这是我运行的:
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
书中陈述如下:
一个包必须包含零个或一个库包,不能更多.它可以包含任意数量的二进制 crate,但必须至少包含一个 crate(库或二进制).
我的疑问是,binary crate 和普通 crate 有什么区别?
My doubt is, what is the difference between binary crates and normal crates?
推荐答案
binary crate 和 library crate 的区别.没有正常"的板条箱.
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.
这篇关于Rust 中的库 crate 和普通 crate 有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!