Add an add_two package

This commit is contained in:
Manuel Thalmann 2025-03-28 21:50:04 +01:00
parent fbf552fb73
commit 1acb5ee469
Signed by: manuth
SSH key fingerprint: SHA256:HsMLC+7kJWALP6YCYCoopxNbUnghwSGLVcG76SECT5c
6 changed files with 18 additions and 0 deletions

5
add/Cargo.lock generated
View file

@ -9,11 +9,16 @@ dependencies = [
"rand",
]
[[package]]
name = "add_two"
version = "0.1.0"
[[package]]
name = "adder"
version = "0.1.0"
dependencies = [
"add_one",
"add_two",
"rand",
]

View file

@ -3,4 +3,5 @@
members = [
"adder",
"add_one",
"add_two",
]

6
add/add_two/Cargo.toml Normal file
View 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
View file

@ -0,0 +1,3 @@
pub fn add_two(x: i32) -> i32 {
x + 2
}

View file

@ -5,4 +5,5 @@ edition = "2024"
[dependencies]
add_one = { path = "../add_one" }
add_two = { path = "../add_two" }
rand = "0.8.5"

View file

@ -1,7 +1,9 @@
use add_one;
use add_two;
use rand;
fn main() {
let num = 10;
println!("Hello, world! {num} plus one is {}!", add_one::add_one(num));
println!("{num} plus two is {}", add_two::add_two(num));
}