From ca6840cec26ac7b2528ef62c157a0e9c43c125fb Mon Sep 17 00:00:00 2001 From: Timothy Warren Date: Mon, 4 Feb 2019 13:27:47 -0500 Subject: [PATCH] Add workspace example (add) --- .idea/misc.xml | 1 + .idea/rust.iml | 10 +++ .idea/workspace.xml | 145 +++++++++++++++++++++++++++++++++++++---- add/Cargo.toml | 6 ++ add/add-one/Cargo.toml | 8 +++ add/add-one/src/lib.rs | 15 +++++ add/adder/Cargo.toml | 9 +++ add/adder/src/main.rs | 6 ++ 8 files changed, 189 insertions(+), 11 deletions(-) create mode 100644 add/Cargo.toml create mode 100644 add/add-one/Cargo.toml create mode 100644 add/add-one/src/lib.rs create mode 100644 add/adder/Cargo.toml create mode 100644 add/adder/src/main.rs diff --git a/.idea/misc.xml b/.idea/misc.xml index b80d65b..ee60ddf 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -23,6 +23,7 @@ + diff --git a/.idea/rust.iml b/.idea/rust.iml index 3f12527..3d5de12 100644 --- a/.idea/rust.iml +++ b/.idea/rust.iml @@ -90,6 +90,16 @@ + + + + + + + + + + diff --git a/.idea/workspace.xml b/.idea/workspace.xml index c72ff77..935ec18 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -27,16 +27,67 @@ - + + + + + + + + + + + + + + + + + + + - + - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -103,6 +154,11 @@ @@ -136,7 +192,33 @@ - + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -180,7 +262,7 @@ - + @@ -327,7 +409,7 @@ - + @@ -344,7 +426,7 @@ - + @@ -675,14 +757,55 @@ - + - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/add/Cargo.toml b/add/Cargo.toml new file mode 100644 index 0000000..d26e7cf --- /dev/null +++ b/add/Cargo.toml @@ -0,0 +1,6 @@ +[workspace] + +members = [ + "adder", + "add-one", +] diff --git a/add/add-one/Cargo.toml b/add/add-one/Cargo.toml new file mode 100644 index 0000000..2a2f5dc --- /dev/null +++ b/add/add-one/Cargo.toml @@ -0,0 +1,8 @@ +[package] +name = "add-one" +version = "0.1.0" +authors = ["Timothy Warren "] +edition = "2018" + +[dependencies] +rand = "0.3.14" diff --git a/add/add-one/src/lib.rs b/add/add-one/src/lib.rs new file mode 100644 index 0000000..f12efc0 --- /dev/null +++ b/add/add-one/src/lib.rs @@ -0,0 +1,15 @@ +use rand; + +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)); + } +} diff --git a/add/adder/Cargo.toml b/add/adder/Cargo.toml new file mode 100644 index 0000000..ba0e032 --- /dev/null +++ b/add/adder/Cargo.toml @@ -0,0 +1,9 @@ +[package] +name = "adder" +version = "0.1.0" +authors = ["Timothy Warren "] +edition = "2018" + +[dependencies] +add-one = { path = "../add-one" } +rand = "0.3.14" diff --git a/add/adder/src/main.rs b/add/adder/src/main.rs new file mode 100644 index 0000000..cec9a65 --- /dev/null +++ b/add/adder/src/main.rs @@ -0,0 +1,6 @@ +use add_one; + +fn main() { + let num = 10; + println!("Hello, world! {} plus one is {}!", num, add_one::add_one(num)); +}