basic/crate-module/crate #721
Replies: 28 comments 26 replies
-
有些资料也叫crate是单元包,package是包,不过只是名称罢了 |
Beta Was this translation helpful? Give feedback.
-
package既然是用来组织项目的,当年为什么不用project? |
Beta Was this translation helpful? Give feedback.
-
有的英文真的不太好翻译成中文,翻译过来总觉得怪怪的 |
Beta Was this translation helpful? Give feedback.
-
WorkSpace不讲一下吗? |
Beta Was this translation helpful? Give feedback.
-
可不可以这样类比:Nginx是一个package,其核心功能入口是lib.rs(库crate),然后分别有start、stop、restart等二进制create? |
Beta Was this translation helpful? Give feedback.
-
这里我觉得作者有点小误会, 同一个 package 下的 bin crate, lib crate 是两个 crate, |
Beta Was this translation helpful? Give feedback.
-
本来不觉得混乱,看完摸不着头脑了,如果一个 Package 同时拥有 src/main.rs 和 src/lib.rs,那就意味着它包含两个包:库包和二进制包,这两个包名也都是 my-project —— 都与 Package 同名。 这两个包名,不是一个main.rs , 一个lib.rs吗,怎么都是my-project ,my-project怎么又与Package同名了? |
Beta Was this translation helpful? Give feedback.
-
|
Beta Was this translation helpful? Give feedback.
-
有点晕,把crate理解成cmake或者makefile里的target好理解一些。 |
Beta Was this translation helpful? Give feedback.
-
package = visual studio 的 solution, crate = visual studio 的 project ? |
Beta Was this translation helpful? Give feedback.
-
我的天,这要是再学学,单词都不够用了。 |
Beta Was this translation helpful? Give feedback.
-
按照 |
Beta Was this translation helpful? Give feedback.
-
我自己把 crate 翻译成 构件 |
Beta Was this translation helpful? Give feedback.
-
一个package可以包含多个crate(一个lib crate和多个bin crate),然后多个package可以组成一个workspace。 可以这样理解吗? |
Beta Was this translation helpful? Give feedback.
-
可能是我太笨了或者没用看仔细,我只会单独使用: |
Beta Was this translation helpful? Give feedback.
-
建议直接用英文名,只对英文名做一个中文概念描述就行了。 |
Beta Was this translation helpful? Give feedback.
-
Rust程序设计语言里面,package翻译成包,crate不翻译。crate是Rust最小编译单位,有二进制和库两种形式。一个包可以有一个或者多个crate。这样更好理解点~ |
Beta Was this translation helpful? Give feedback.
-
建议备注下,cd my-project 之后运行 |
Beta Was this translation helpful? Give feedback.
-
看完我更迷糊了。。crate 和 package 我觉得是一个意思。。。 |
Beta Was this translation helpful? Give feedback.
-
看完确实更晕了,这个阶段代码都没有办法敲流畅,不如简单点解释,未来深入了再探究。 package: 含有1个以上crate的集合。 my_package/
├── Cargo.toml
├── src/
│ ├── main.rs <-- 主 crate 的源文件
│ └── lib.rs <-- 如果有的话,库 crate 的源文件
├── other_crate1/ <-- 其他 crate 1
│ ├── Cargo.toml <-- 其他 crate 1 的元数据
│ └── src/
│ ├── my_mod.rs <-- 其他 crate 1 中的模块
│ └── main.rs <-- 其他 crate 1 的 main 或者 lib 文件
└── other_crate2/ <-- 其他 crate 2
├── Cargo.toml <-- 其他 crate 2 的元数据
└── src/
├── my_mod.rs <-- 其他 crate 2 中的模块
└── main.rs <-- 其他 crate 2 的 main 或者 lib 文件 |
Beta Was this translation helpful? Give feedback.
-
这个水平还是别翻了吧,劝退了多少人 |
Beta Was this translation helpful? Give feedback.
-
学习打卡,再接再厉 |
Beta Was this translation helpful? Give feedback.
-
说实话 这节讲的云里雾里 |
Beta Was this translation helpful? Give feedback.
-
遇到一个Crate的编译问题,无法理解,请各位大佬指点迷津,报错信息如下:
请问出错的原因是什么,如何解决这个编译问题? 测试代码目录结构如下:
一个workspace 仅包含一个二进制package(refer),顶层workspace的Cargo.toml 的内容如下:
二进制package 的refer/Cargo.toml 内容如下:
refer/src/main.rs的内容如下:
|
Beta Was this translation helpful? Give feedback.
-
这一章能看懂的,能有1%吗? |
Beta Was this translation helpful? Give feedback.
-
说实话,前面的章节都没有这章看的一头雾水,来自一个新手的困惑,不在于翻译的问题,而在于里面内在的逻辑关系。例如原文(是二进制包的根文件,该二进制包的包名跟所属 Package 相同,在这里都是 my-project)里面二进制包的包名从哪指定的,可变吗?toml文件中的name=my-project是在指定项目名吗?cargo new的时候创建的新文件夹my-project是项目名吗?cargo build后的可执行文件或包文件名称是由谁指定的,是toml文件中的name吗? 一头雾水。。。。。 |
Beta Was this translation helpful? Give feedback.
-
basic/crate-module/crate
https://course.rs/basic/crate-module/crate.html
Beta Was this translation helpful? Give feedback.
All reactions