标签:pac mod init png pre reference end dde inf
这是为了开发大型程序,分治crate用的。
目录结构如下:
一,根cargo.toml内容
[workspace]
members = [
"adder",
"add-one",
]
二,adder里的cargo.toml内容
[package] name = "adder" version = "0.1.0" authors = ["test <test@qq.com>"] edition = "2018" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] add-one = { path = "../add-one" }
三,main.rs内容
use add_one; fn main() { let num = 10; println!("Hello, world! {} plus one is {}!", num, add_one::add_one(num)); }
四,Lib.rs内容
pub fn add_one(x: i32) -> i32 { x + 1 } #[cfg(test)] mod tests { use super::*; #[test] fn it_works() { assert_eq!(3, add_one(2)); } }
标签:pac mod init png pre reference end dde inf
原文地址:https://www.cnblogs.com/aguncn/p/11439898.html