参考 https://blog.csdn.net/quicmous/article/details/113829830
1 创建工程
选择合适的文件夹,执行下面的命令:
cargo new hello cargo new helloblib --lib
2. 源代码
hellolib/src/lib.rs:
pub fn say(){ println!("hello!"); }
hello/src/main.rs:
extern crate hellolib; fn main(){ hellolib::say(); }
hello/Cargo.toml: 添加依赖项 hellolib = { path = "../hellolib"}
编译运行,一切都妥妥的!