我正在寻找与mvn install
等效的命令。虽然这个问题并不完全是我的原始问题的重复,但任何偶然发现我的原始问题并跟随链接到这里的人都会找到更完整的答案。
答案是“没有与mvn install
等效的命令,因为您必须在Cargo.toml文件中硬编码路径,这可能在其他人的计算机上出错,但您可以接近实现目标。”
现有的答案有点简略,我不得不花费更长的时间才能使事情真正起作用,所以这里提供更多细节:
/usr/bin/cargo run --color=always --package re5 --bin re5
Compiling re5 v0.1.0 (file:///home/thoth/art/2019/radial-embroidery/re5)
error[E0432]: unresolved import `embroidery_stitcher`
--> re5/src/main.rs:5:5
|
5 | use embroidery_stitcher;
| ^^^^^^^^^^^^^^^^^^^ no `embroidery_stitcher` in the root
rustc --explain E0432
包含了这段话,重复了Shepmaster的回答:
Or, if you tried to use a module from an external crate, you may have missed
the extern crate
declaration (which is usually placed in the crate root):
extern crate core;
use core::any;
从use
切换到extern crate
给了我以下结果:
/usr/bin/cargo run --color=always --package re5 --bin re5
Compiling embroidery_stitcher v0.1.0 (file:///home/thoth/art/2019/radial-embroidery/embroidery_stitcher)
warning: function is never used: `svg_header`
--> embroidery_stitcher/src/lib.rs:2:1
|
2 | fn svg_header(w: i32, h: i32) -> String
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: #[warn(dead_code)] on by default
Compiling re5 v0.1.0 (file:///home/thoth/art/2019/radial-embroidery/re5)
error[E0603]: function `svg_header` is private
--> re5/src/main.rs:8:19
|
8 | let mut svg = embroidery_stitcher::svg_header(100,100);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
我不得不在那个函数前面加上一个pub
pub fn svg_header(w: i32, h: i32) -> String
现在它能够正常工作了。
git
而不是version
来实现相同的效果吗?例如my_lib = { path = "...", git = "..." }
这样我就可以在开发过程中使用本地副本,在有人克隆存储库并尝试编译程序时使用远程git。 - Ruben Kostandyan