"首次提交"
This commit is contained in:
2
workspace_learn/add/Cargo.toml
Executable file
2
workspace_learn/add/Cargo.toml
Executable file
@ -0,0 +1,2 @@
|
||||
[workspace]
|
||||
members = ["adder", "add-one", "adder1"]
|
1
workspace_learn/add/add-one/.gitignore
vendored
Executable file
1
workspace_learn/add/add-one/.gitignore
vendored
Executable file
@ -0,0 +1 @@
|
||||
/target
|
9
workspace_learn/add/add-one/Cargo.toml
Executable file
9
workspace_learn/add/add-one/Cargo.toml
Executable file
@ -0,0 +1,9 @@
|
||||
[package]
|
||||
name = "add-one"
|
||||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[dependencies]
|
||||
rand = "0.7.3"
|
14
workspace_learn/add/add-one/src/lib.rs
Executable file
14
workspace_learn/add/add-one/src/lib.rs
Executable file
@ -0,0 +1,14 @@
|
||||
pub fn add(left: usize, right: usize) -> usize {
|
||||
left + right
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn it_works() {
|
||||
let result = add(2, 2);
|
||||
assert_eq!(result, 4);
|
||||
}
|
||||
}
|
1
workspace_learn/add/adder/.gitignore
vendored
Executable file
1
workspace_learn/add/adder/.gitignore
vendored
Executable file
@ -0,0 +1 @@
|
||||
/target
|
9
workspace_learn/add/adder/Cargo.toml
Executable file
9
workspace_learn/add/adder/Cargo.toml
Executable file
@ -0,0 +1,9 @@
|
||||
[package]
|
||||
name = "adder"
|
||||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[dependencies]
|
||||
add-one = { path = "../add-one" }
|
10
workspace_learn/add/adder/src/main.rs
Executable file
10
workspace_learn/add/adder/src/main.rs
Executable file
@ -0,0 +1,10 @@
|
||||
use add_one;
|
||||
fn main() {
|
||||
println!("Hello, world!");
|
||||
add_one::add(1, 2);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn it_works_add_one() {
|
||||
assert_eq!(add_one::add(1, 2), 3);
|
||||
}
|
1
workspace_learn/add/adder1/.gitignore
vendored
Executable file
1
workspace_learn/add/adder1/.gitignore
vendored
Executable file
@ -0,0 +1 @@
|
||||
/target
|
10
workspace_learn/add/adder1/Cargo.toml
Executable file
10
workspace_learn/add/adder1/Cargo.toml
Executable file
@ -0,0 +1,10 @@
|
||||
[package]
|
||||
name = "adder1"
|
||||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[dependencies]
|
||||
rand = "0.8.5"
|
||||
add-one = { path = "../add-one" }
|
5
workspace_learn/add/adder1/src/main.rs
Executable file
5
workspace_learn/add/adder1/src/main.rs
Executable file
@ -0,0 +1,5 @@
|
||||
use add_one;
|
||||
fn main() {
|
||||
println!("Hello, world!");
|
||||
println!("2 + 3 = {}", add_one::add(2, 3));
|
||||
}
|
Reference in New Issue
Block a user