Add an add_two
package
This commit is contained in:
parent
fbf552fb73
commit
1acb5ee469
6 changed files with 18 additions and 0 deletions
add
5
add/Cargo.lock
generated
5
add/Cargo.lock
generated
|
@ -9,11 +9,16 @@ dependencies = [
|
||||||
"rand",
|
"rand",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "add_two"
|
||||||
|
version = "0.1.0"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "adder"
|
name = "adder"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"add_one",
|
"add_one",
|
||||||
|
"add_two",
|
||||||
"rand",
|
"rand",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
|
@ -3,4 +3,5 @@
|
||||||
members = [
|
members = [
|
||||||
"adder",
|
"adder",
|
||||||
"add_one",
|
"add_one",
|
||||||
|
"add_two",
|
||||||
]
|
]
|
||||||
|
|
6
add/add_two/Cargo.toml
Normal file
6
add/add_two/Cargo.toml
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
[package]
|
||||||
|
name = "add_two"
|
||||||
|
version = "0.1.0"
|
||||||
|
edition = "2024"
|
||||||
|
|
||||||
|
[dependencies]
|
3
add/add_two/src/lib.rs
Normal file
3
add/add_two/src/lib.rs
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
pub fn add_two(x: i32) -> i32 {
|
||||||
|
x + 2
|
||||||
|
}
|
|
@ -5,4 +5,5 @@ edition = "2024"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
add_one = { path = "../add_one" }
|
add_one = { path = "../add_one" }
|
||||||
|
add_two = { path = "../add_two" }
|
||||||
rand = "0.8.5"
|
rand = "0.8.5"
|
||||||
|
|
|
@ -1,7 +1,9 @@
|
||||||
use add_one;
|
use add_one;
|
||||||
|
use add_two;
|
||||||
use rand;
|
use rand;
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
let num = 10;
|
let num = 10;
|
||||||
println!("Hello, world! {num} plus one is {}!", add_one::add_one(num));
|
println!("Hello, world! {num} plus one is {}!", add_one::add_one(num));
|
||||||
|
println!("{num} plus two is {}", add_two::add_two(num));
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue