summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdam Carpenter <adam.carpenter@adp.com>2019-02-11 16:59:01 -0500
committerAdam Carpenter <adam.carpenter@adp.com>2019-02-11 16:59:01 -0500
commitef1bf4921ee4127d461eec03a14c9070d193345c (patch)
treeab9f4ed73fcf97656743c959ce8c9adbe2ce9924
downloadlearning-rust-ef1bf4921ee4127d461eec03a14c9070d193345c.tar.xz
learning-rust-ef1bf4921ee4127d461eec03a14c9070d193345c.zip
Init.
-rwxr-xr-xcollections/.gitignore2
-rwxr-xr-xcollections/Cargo.lock4
-rwxr-xr-xcollections/Cargo.toml7
-rwxr-xr-xcollections/src/main.rs133
-rwxr-xr-xcontrol/.gitignore2
-rwxr-xr-xcontrol/Cargo.lock4
-rwxr-xr-xcontrol/Cargo.toml7
-rwxr-xr-xcontrol/src/main.rs7
m---------employees0
-rwxr-xr-xenums/.gitignore2
-rwxr-xr-xenums/Cargo.lock4
-rwxr-xr-xenums/Cargo.toml7
-rwxr-xr-xenums/src/main.rs12
-rwxr-xr-xenums/src/main1.rs48
-rw-r--r--errors/.gitignore2
-rw-r--r--errors/Cargo.lock4
-rw-r--r--errors/Cargo.toml7
-rw-r--r--errors/src/main.rs38
-rw-r--r--fibonacci/.gitignore2
-rw-r--r--fibonacci/Cargo.lock4
-rw-r--r--fibonacci/Cargo.toml7
-rw-r--r--fibonacci/src/main.rs31
-rw-r--r--ftoctof/.gitignore2
-rw-r--r--ftoctof/Cargo.lock4
-rw-r--r--ftoctof/Cargo.toml7
-rw-r--r--ftoctof/src/main.rs43
-rwxr-xr-xfunctions/.gitignore2
-rwxr-xr-xfunctions/Cargo.lock4
-rwxr-xr-xfunctions/Cargo.toml7
-rwxr-xr-xfunctions/src/main.rs10
-rw-r--r--generics/.gitignore2
-rw-r--r--generics/Cargo.lock4
-rw-r--r--generics/Cargo.toml7
-rw-r--r--generics/src/main.rs68
-rwxr-xr-xguessing-game/.gitignore2
-rwxr-xr-xguessing-game/Cargo.lock80
-rwxr-xr-xguessing-game/Cargo.toml8
-rwxr-xr-xguessing-game/src/main.rs36
-rwxr-xr-xhello_world/hello_cargo/.gitignore2
-rwxr-xr-xhello_world/hello_cargo/Cargo.lock4
-rwxr-xr-xhello_world/hello_cargo/Cargo.toml7
-rwxr-xr-xhello_world/hello_cargo/src/main.rs3
-rwxr-xr-xhello_world/main.exebin0 -> 4129619 bytes
-rwxr-xr-xhello_world/main.rs4
-rwxr-xr-xhorcrux/.gitignore2
-rwxr-xr-xhorcrux/Cargo.toml7
-rwxr-xr-xhorcrux/src/main.rs3
-rw-r--r--mathsssss/.gitignore2
-rw-r--r--mathsssss/Cargo.lock4
-rw-r--r--mathsssss/Cargo.toml7
-rw-r--r--mathsssss/src/main.rs61
-rwxr-xr-xownership/.gitignore2
-rwxr-xr-xownership/Cargo.lock4
-rwxr-xr-xownership/Cargo.toml7
-rwxr-xr-xownership/src/main.rs51
-rwxr-xr-xpackages/my-project/.gitignore2
-rwxr-xr-xpackages/my-project/Cargo.lock4
-rwxr-xr-xpackages/my-project/Cargo.toml7
-rwxr-xr-xpackages/my-project/src/main.rs82
-rwxr-xr-xpackages/my-project/src/sound.rs1
-rwxr-xr-xpackages/my-project/src/sound/instrument.rs3
-rw-r--r--piglatin/.gitignore2
-rw-r--r--piglatin/Cargo.lock4
-rw-r--r--piglatin/Cargo.toml7
-rw-r--r--piglatin/src/main.rs38
m---------rust-csci4150
-rwxr-xr-xstructs/.gitignore2
-rwxr-xr-xstructs/Cargo.lock4
-rwxr-xr-xstructs/Cargo.toml7
-rwxr-xr-xstructs/src/main.rs32
-rwxr-xr-xstructs/src/main.rs.bak36
-rw-r--r--traits/.gitignore2
-rw-r--r--traits/Cargo.lock4
-rw-r--r--traits/Cargo.toml7
-rw-r--r--traits/src/main.rs114
-rwxr-xr-xvariables/.gitignore2
-rwxr-xr-xvariables/Cargo.lock4
-rwxr-xr-xvariables/Cargo.toml7
-rwxr-xr-xvariables/src/main.rs6
-rw-r--r--xmas/.gitignore2
-rw-r--r--xmas/Cargo.lock4
-rw-r--r--xmas/Cargo.toml7
-rw-r--r--xmas/out.txt114
-rw-r--r--xmas/src/main.rs42
84 files changed, 1336 insertions, 0 deletions
diff --git a/collections/.gitignore b/collections/.gitignore
new file mode 100755
index 0000000..53eaa21
--- /dev/null
+++ b/collections/.gitignore
@@ -0,0 +1,2 @@
+/target
+**/*.rs.bk
diff --git a/collections/Cargo.lock b/collections/Cargo.lock
new file mode 100755
index 0000000..14856a6
--- /dev/null
+++ b/collections/Cargo.lock
@@ -0,0 +1,4 @@
+[[package]]
+name = "collections"
+version = "0.1.0"
+
diff --git a/collections/Cargo.toml b/collections/Cargo.toml
new file mode 100755
index 0000000..8460a0c
--- /dev/null
+++ b/collections/Cargo.toml
@@ -0,0 +1,7 @@
+[package]
+name = "collections"
+version = "0.1.0"
+authors = ["Adam Carpenter <carpenat@ES.AD.ADP.COM>"]
+edition = "2018"
+
+[dependencies]
diff --git a/collections/src/main.rs b/collections/src/main.rs
new file mode 100755
index 0000000..7257ce2
--- /dev/null
+++ b/collections/src/main.rs
@@ -0,0 +1,133 @@
+use std::collections::HashMap;
+
+fn main() {
+ //let v: Vec<i32> = Vec::new();
+ //let mut v = vec![1, 2, 3, 4, 5];
+
+ // let third: &i32 = &v[2];
+ // println!("the third element is {}", third);
+ //
+ // match v.get(2) {
+ // Some(third) => println!("third is {}", third),
+ // None => println!("no third element"),
+ // }
+ //
+ // for i in &mut v {
+ // *i += 10;
+ // println!("{}", *i);
+ // }
+ // for i in &v {
+ // println!("{}", i);
+ // }
+
+ // enum SpreadsheetCell {
+ // Int(i32),
+ // Float(f64),
+ // Text(String),
+ // }
+ //
+ // let row = vec![
+ // SpreadsheetCell::Int(3),
+ // SpreadsheetCell::Text(String::from("blue")),
+ // SpreadsheetCell::Float(10.12),
+ // ];
+
+ //let mut s = String::new();
+
+ //let data = "initial contents";
+ //let s = data.to_string();
+ //dbg!(s);
+ //let s = "initial contents".to_string();
+ //dbg!(s);
+ //let s = String::from("initial contents");
+ //dbg!(s);
+
+ //let mut s = String::from("hello");
+ //s.push_str(" world");
+
+ //let mut s1 = String::from("hello");
+ //let s2 = " world";
+ //s1.push_str(s2);
+ //s1.push('!');
+ //dbg!(s1);
+
+ //let s1 = String::from("Hello ");
+ //let s2 = String::from("world");
+ //let s3 = s1 + &s2 + "!";
+ //dbg!(s3);
+
+ //let my_result: Result<&'static str, &'static str> = Ok("test");
+
+ //dbg!(my_result);
+
+ //let s1 = String::from("tic");
+ //let s2 = String::from("tac");
+ //let s3 = String::from("toe");
+
+ //let s = format!("{}-{}-{}", s1, s2, s3);
+ //dbg!(s);
+
+ //let s = String::from("welcome to hello world");
+ //let len = s.len();
+ //dbg!(len);
+ //let s1 = s[0..15].to_string();
+ //dbg!(s1);
+
+ //for c in "hello world".bytes() {
+ // dbg!(c);
+ //}
+
+ //let mut scores = HashMap::new();
+ //scores.insert(String::from("Blue"), 10);
+ //scores.insert(String::from("Yellow"), 50);
+ //scores.insert(String::from("Blue"), 20);
+ //dbg!(scores);
+
+ //let teams = vec![String::from("blue"), String::from("yellow")];
+ //let initial_scores = vec![10, 20];
+ //let scores: HashMap<_, _> = teams.iter().zip(initial_scores.iter()).collect();
+ //dbg!(scores);
+
+ //let field_name = String::from("favorite color");
+ //let field_value = String::from("blue");
+
+ //let mut map = HashMap::new();
+ //map.insert(field_name, field_value);
+
+ //let mut scores = HashMap::new();
+ //scores.insert(String::from("blue"), 10);
+ //scores.insert(String::from("yellow"), 50);
+
+ //let team_name = String::from("blue");
+ //let score = scores.get(&team_name);
+
+ //dbg!(team_name);
+ //dbg!(score);
+
+ //let mut scores = HashMap::new();
+
+ //scores.insert(String::from("blue"), 10);
+ //scores.insert(String::from("yellow"), 50);
+
+ //for (key, value) in &scores {
+ // dbg!(key);
+ // dbg!(value);
+ //}
+
+ // let mut scores = HashMap::new();
+ // scores.insert(String::from("blue"), 10);
+ // scores.entry(String::from("yellow")).or_insert(50);
+ // scores.entry(String::from("blue")).or_insert(50);
+ // dbg!(scores);
+
+ //let text = "when in the course of himan events it becomes necessary for one people to dissolve the political bands which have connected them with another and to assume among the powers of the earth the separate and equal station to which thelaws of nature and of nature's God entitle them a decent respect to the opinions of mankind requires that they should declare the causes which impel them to the separation";
+ //let mut map = HashMap::new();
+
+ //for word in text.split_whitespace() {
+ // let count = map.entry(word).or_insert(0);
+ // *count += 1;
+ //}
+
+ //dbg!(map);
+
+}
diff --git a/control/.gitignore b/control/.gitignore
new file mode 100755
index 0000000..53eaa21
--- /dev/null
+++ b/control/.gitignore
@@ -0,0 +1,2 @@
+/target
+**/*.rs.bk
diff --git a/control/Cargo.lock b/control/Cargo.lock
new file mode 100755
index 0000000..81a9861
--- /dev/null
+++ b/control/Cargo.lock
@@ -0,0 +1,4 @@
+[[package]]
+name = "control"
+version = "0.1.0"
+
diff --git a/control/Cargo.toml b/control/Cargo.toml
new file mode 100755
index 0000000..70b4d1d
--- /dev/null
+++ b/control/Cargo.toml
@@ -0,0 +1,7 @@
+[package]
+name = "control"
+version = "0.1.0"
+authors = ["Adam Carpenter <carpenat@ES.AD.ADP.COM>"]
+edition = "2018"
+
+[dependencies]
diff --git a/control/src/main.rs b/control/src/main.rs
new file mode 100755
index 0000000..0b74683
--- /dev/null
+++ b/control/src/main.rs
@@ -0,0 +1,7 @@
+fn main() {
+
+ for number in (1..1000).rev() {
+ println!("{}", number);
+ }
+}
+
diff --git a/employees b/employees
new file mode 160000
+Subproject db1600def1822679e51e8917c8b4731c8f47781
diff --git a/enums/.gitignore b/enums/.gitignore
new file mode 100755
index 0000000..53eaa21
--- /dev/null
+++ b/enums/.gitignore
@@ -0,0 +1,2 @@
+/target
+**/*.rs.bk
diff --git a/enums/Cargo.lock b/enums/Cargo.lock
new file mode 100755
index 0000000..d3577dd
--- /dev/null
+++ b/enums/Cargo.lock
@@ -0,0 +1,4 @@
+[[package]]
+name = "enums"
+version = "0.1.0"
+
diff --git a/enums/Cargo.toml b/enums/Cargo.toml
new file mode 100755
index 0000000..99fb9fc
--- /dev/null
+++ b/enums/Cargo.toml
@@ -0,0 +1,7 @@
+[package]
+name = "enums"
+version = "0.1.0"
+authors = ["Adam Carpenter <carpenat@ES.AD.ADP.COM>"]
+edition = "2018"
+
+[dependencies]
diff --git a/enums/src/main.rs b/enums/src/main.rs
new file mode 100755
index 0000000..b8c61de
--- /dev/null
+++ b/enums/src/main.rs
@@ -0,0 +1,12 @@
+fn main() {
+ let some_u8_value = Some(3u8);
+// match some_u8_value {
+// Some(3) => println!("three"),
+// _ => (),
+// }
+
+ if let Some(3) = some_u8_value {
+ println!("three");
+ }
+
+}
diff --git a/enums/src/main1.rs b/enums/src/main1.rs
new file mode 100755
index 0000000..9670693
--- /dev/null
+++ b/enums/src/main1.rs
@@ -0,0 +1,48 @@
+#[derive(Debug)]
+enum UsState {
+ NY,
+ VA,
+ NC,
+}
+
+enum Coin {
+ Penny,
+ Nickel,
+ Dime,
+ Quarter(UsState),
+}
+
+impl Coin {
+
+ fn value_in_cents(self) -> u32 {
+
+ match self {
+ Coin::Penny => {
+ println!("lucky penny");
+ 1
+ },
+ Coin::Nickel => 5,
+ Coin::Dime => 10,
+ Coin::Quarter(state) => {
+ println!("State quarter from {:?}", state);
+ 25
+ },
+
+ }
+
+ }
+}
+
+fn plus_one(x: Option<i32>) -> Option<i32> {
+
+ match x {
+ None => None,
+ Some(i) => Some(i + 1),
+ }
+}
+
+fn main() {
+ let five = Some(5);
+ let six = plus_one(five);
+ let none = plus_one(None);
+}
diff --git a/errors/.gitignore b/errors/.gitignore
new file mode 100644
index 0000000..53eaa21
--- /dev/null
+++ b/errors/.gitignore
@@ -0,0 +1,2 @@
+/target
+**/*.rs.bk
diff --git a/errors/Cargo.lock b/errors/Cargo.lock
new file mode 100644
index 0000000..749984f
--- /dev/null
+++ b/errors/Cargo.lock
@@ -0,0 +1,4 @@
+[[package]]
+name = "errors"
+version = "0.1.0"
+
diff --git a/errors/Cargo.toml b/errors/Cargo.toml
new file mode 100644
index 0000000..e531a1b
--- /dev/null
+++ b/errors/Cargo.toml
@@ -0,0 +1,7 @@
+[package]
+name = "errors"
+version = "0.1.0"
+authors = ["Adam Carpenter <adam.carpenter@adp.com>"]
+edition = "2018"
+
+[dependencies]
diff --git a/errors/src/main.rs b/errors/src/main.rs
new file mode 100644
index 0000000..1250677
--- /dev/null
+++ b/errors/src/main.rs
@@ -0,0 +1,38 @@
+use std::io;
+use std::io::Read;
+use std::fs::File;
+//use std::io::ErrorKind;
+
+fn read_username_from_file() -> Result<String, io::Error> {
+// let f = File::open("hello.txt");
+// let mut f = match f {
+// Ok(file) => file,
+// Err(e) => return Err(e),
+// };
+// let mut s = String::new();
+// match f.read_to_string(&mut s) {
+// Ok(_) => Ok(s),
+// Err(e) => Err(e),
+// }
+ let mut s = String::new();
+ File::open("hello.txt")?.read_to_string(&mut s)?;
+ Ok(s)
+}
+fn main() {
+// let f = File::open("hello.txt").map_err(|error| {
+// if error.kind() == ErrorKind::NotFound {
+// File::create("hello.txt").unwrap_or_else(|error| {
+// panic!("Could not create file: {:?}", error);
+// })
+// }
+// else {
+// panic!("Problem opening file: {:?}", error);
+// }
+// });
+
+ //let f = File::open("hello.txt").unwrap();
+
+ //let f = File::open("hello.txt").expect("failed to open hello.txt");
+
+ dbg!(read_username_from_file());
+}
diff --git a/fibonacci/.gitignore b/fibonacci/.gitignore
new file mode 100644
index 0000000..53eaa21
--- /dev/null
+++ b/fibonacci/.gitignore
@@ -0,0 +1,2 @@
+/target
+**/*.rs.bk
diff --git a/fibonacci/Cargo.lock b/fibonacci/Cargo.lock
new file mode 100644
index 0000000..06aa71c
--- /dev/null
+++ b/fibonacci/Cargo.lock
@@ -0,0 +1,4 @@
+[[package]]
+name = "fibonacci"
+version = "0.1.0"
+
diff --git a/fibonacci/Cargo.toml b/fibonacci/Cargo.toml
new file mode 100644
index 0000000..60bf227
--- /dev/null
+++ b/fibonacci/Cargo.toml
@@ -0,0 +1,7 @@
+[package]
+name = "fibonacci"
+version = "0.1.0"
+authors = ["Adam Carpenter <adam.carpenter@adp.com>"]
+edition = "2018"
+
+[dependencies]
diff --git a/fibonacci/src/main.rs b/fibonacci/src/main.rs
new file mode 100644
index 0000000..0b4f22b
--- /dev/null
+++ b/fibonacci/src/main.rs
@@ -0,0 +1,31 @@
+use std::env;
+
+fn fib(n: u32) -> u32 {
+
+ if n == 0 || n == 1 {
+ return n;
+ }
+ else {
+ return fib(n - 1) + fib(n - 2);
+ }
+
+}
+
+fn main() {
+ // grab iterations
+ let iterations: u32 = match env::args().nth(1) {
+ Some(s) => {
+ let attempt: u32 = s.trim().parse()
+ .expect("error: could not parse iterations");
+ attempt
+ },
+ None => {
+ eprintln!("error: usage: fibonacci [iterations]");
+ return;
+ },
+ };
+
+ for i in 0..iterations {
+ println!("{}", fib(i));
+ }
+}
diff --git a/ftoctof/.gitignore b/ftoctof/.gitignore
new file mode 100644
index 0000000..53eaa21
--- /dev/null
+++ b/ftoctof/.gitignore
@@ -0,0 +1,2 @@
+/target
+**/*.rs.bk
diff --git a/ftoctof/Cargo.lock b/ftoctof/Cargo.lock
new file mode 100644
index 0000000..e716471
--- /dev/null
+++ b/ftoctof/Cargo.lock
@@ -0,0 +1,4 @@
+[[package]]
+name = "ftoctof"
+version = "0.1.0"
+
diff --git a/ftoctof/Cargo.toml b/ftoctof/Cargo.toml
new file mode 100644
index 0000000..544eb2b
--- /dev/null
+++ b/ftoctof/Cargo.toml
@@ -0,0 +1,7 @@
+[package]
+name = "ftoctof"
+version = "0.1.0"
+authors = ["Adam Carpenter <adam.carpenter@adp.com>"]
+edition = "2018"
+
+[dependencies]
diff --git a/ftoctof/src/main.rs b/ftoctof/src/main.rs
new file mode 100644
index 0000000..6425344
--- /dev/null
+++ b/ftoctof/src/main.rs
@@ -0,0 +1,43 @@
+use std::env;
+
+fn print_usage() {
+ eprintln!("error: usage: ftoctof [degrees] [f|c]");
+}
+
+fn main() {
+ // grab degrees value
+ let degrees: f32 = match env::args().nth(1) {
+ Some(s) => {
+ let attempt: f32 = s.trim().parse()
+ .expect("error: could not parse degrees");
+ attempt
+ },
+ None => {
+ print_usage();
+ return;
+ },
+ };
+
+ // grab scale identifier
+ let scale = match env::args().nth(2) {
+ Some(s) => s.to_lowercase(),
+ None => {
+ print_usage();
+ return;
+ },
+ };
+
+ // compute and print conversion
+ if scale == "f" {
+ let result: f32 = (degrees - 32.0) * 5.0 / 9.0;
+ println!("{} degrees fahrenheight is {} degrees celcius.", degrees, result);
+ }
+ else if scale == "c" {
+ let result: f32 = degrees * 9.0 / 5.0 + 32.0;
+ println!("{} degrees celcius is {} degrees fahrenheight.", degrees, result);
+ }
+ else {
+ print_usage();
+ }
+
+}
diff --git a/functions/.gitignore b/functions/.gitignore
new file mode 100755
index 0000000..53eaa21
--- /dev/null
+++ b/functions/.gitignore
@@ -0,0 +1,2 @@
+/target
+**/*.rs.bk
diff --git a/functions/Cargo.lock b/functions/Cargo.lock
new file mode 100755
index 0000000..89a654d
--- /dev/null
+++ b/functions/Cargo.lock
@@ -0,0 +1,4 @@
+[[package]]
+name = "functions"
+version = "0.1.0"
+
diff --git a/functions/Cargo.toml b/functions/Cargo.toml
new file mode 100755
index 0000000..656b779
--- /dev/null
+++ b/functions/Cargo.toml
@@ -0,0 +1,7 @@
+[package]
+name = "functions"
+version = "0.1.0"
+authors = ["Adam Carpenter <carpenat@ES.AD.ADP.COM>"]
+edition = "2018"
+
+[dependencies]
diff --git a/functions/src/main.rs b/functions/src/main.rs
new file mode 100755
index 0000000..43284ff
--- /dev/null
+++ b/functions/src/main.rs
@@ -0,0 +1,10 @@
+fn main() {
+ let x = plus_one(5);
+
+ println!("The value of x is {}", x);
+}
+
+fn plus_one(x: i32) -> i32 {
+ x + 1
+}
+
diff --git a/generics/.gitignore b/generics/.gitignore
new file mode 100644
index 0000000..53eaa21
--- /dev/null
+++ b/generics/.gitignore
@@ -0,0 +1,2 @@
+/target
+**/*.rs.bk
diff --git a/generics/Cargo.lock b/generics/Cargo.lock
new file mode 100644
index 0000000..3ddbc8c
--- /dev/null
+++ b/generics/Cargo.lock
@@ -0,0 +1,4 @@
+[[package]]
+name = "generics"
+version = "0.1.0"
+
diff --git a/generics/Cargo.toml b/generics/Cargo.toml
new file mode 100644
index 0000000..5529f73
--- /dev/null
+++ b/generics/Cargo.toml
@@ -0,0 +1,7 @@
+[package]
+name = "generics"
+version = "0.1.0"
+authors = ["Adam Carpenter <adam.carpenter@adp.com>"]
+edition = "2018"
+
+[dependencies]
diff --git a/generics/src/main.rs b/generics/src/main.rs
new file mode 100644
index 0000000..e41d6f5
--- /dev/null
+++ b/generics/src/main.rs
@@ -0,0 +1,68 @@
+//struct Point<T, U> {
+// x: T,
+// y: U,
+//}
+
+//impl<T, U> Point<T, U> {
+// fn x(&self) -> &T {
+// &self.x
+// }
+//
+// fn y(&self) -> &T {
+// &self.y
+// }
+
+// fn mixup<V, W>(self, other: Point<V, W>) -> Point<T, W> {
+// Point {
+// x: self.x,
+// y: other.y,
+// }
+// }
+//}
+
+fn largest<T: PartialOrd + Copy>(list: &[T]) -> T {
+ let mut largest = list[0];
+
+ for &item in list.iter() {
+
+ if item > largest {
+ largest = item;
+ }
+
+ }
+
+ largest
+}
+
+//enum Option_i32 {
+// Some(i32),
+// None,
+//}
+//
+//enum Option_f64 {
+// Some(f64),
+// None,
+//}
+
+fn main() {
+ let number_list = vec![34, 50, 25, 100, 65];
+ dbg!(largest(&number_list));
+ let char_list = vec!['h', 'e', 'l', 'l', 'o'];
+ dbg!(largest(&char_list));
+// let integer = Point { x: 5, y: 10 };
+// let float = Point { x: 5.0, y: 10.0 };
+
+// let p = Point { x: 5.0, y: 10.5 };
+// dbg!(p.x());
+// dbg!(p.y());
+
+// let p1 = Point { x: 5, y: 10.4 };
+// let p2 = Point { x: "Hello", y: 'c' };
+// let p3 = p1.mixup(p2);
+//
+// dbg!(p3.x);
+// dbg!(p3.y);
+
+// let integer = Option_i32::Some(5);
+// let float = Option_f64::Some(5.0);
+}
diff --git a/guessing-game/.gitignore b/guessing-game/.gitignore
new file mode 100755
index 0000000..53eaa21
--- /dev/null
+++ b/guessing-game/.gitignore
@@ -0,0 +1,2 @@
+/target
+**/*.rs.bk
diff --git a/guessing-game/Cargo.lock b/guessing-game/Cargo.lock
new file mode 100755
index 0000000..c25e3df
--- /dev/null
+++ b/guessing-game/Cargo.lock
@@ -0,0 +1,80 @@
+[[package]]
+name = "bitflags"
+version = "1.0.4"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+
+[[package]]
+name = "fuchsia-zircon"
+version = "0.3.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+dependencies = [
+ "bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)",
+ "fuchsia-zircon-sys 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)",
+]
+
+[[package]]
+name = "fuchsia-zircon-sys"
+version = "0.3.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+
+[[package]]
+name = "guessing-game"
+version = "0.1.0"
+dependencies = [
+ "rand 0.3.22 (registry+https://github.com/rust-lang/crates.io-index)",
+]
+
+[[package]]
+name = "libc"
+version = "0.2.45"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+
+[[package]]
+name = "rand"
+version = "0.3.22"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+dependencies = [
+ "fuchsia-zircon 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)",
+ "libc 0.2.45 (registry+https://github.com/rust-lang/crates.io-index)",
+ "rand 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)",
+]
+
+[[package]]
+name = "rand"
+version = "0.4.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+dependencies = [
+ "fuchsia-zircon 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)",
+ "libc 0.2.45 (registry+https://github.com/rust-lang/crates.io-index)",
+ "winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)",
+]
+
+[[package]]
+name = "winapi"
+version = "0.3.6"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+dependencies = [
+ "winapi-i686-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
+ "winapi-x86_64-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
+]
+
+[[package]]
+name = "winapi-i686-pc-windows-gnu"
+version = "0.4.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+
+[[package]]
+name = "winapi-x86_64-pc-windows-gnu"
+version = "0.4.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+
+[metadata]
+"checksum bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "228047a76f468627ca71776ecdebd732a3423081fcf5125585bcd7c49886ce12"
+"checksum fuchsia-zircon 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "2e9763c69ebaae630ba35f74888db465e49e259ba1bc0eda7d06f4a067615d82"
+"checksum fuchsia-zircon-sys 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "3dcaa9ae7725d12cdb85b3ad99a434db70b468c09ded17e012d86b5c1010f7a7"
+"checksum libc 0.2.45 (registry+https://github.com/rust-lang/crates.io-index)" = "2d2857ec59fadc0773853c664d2d18e7198e83883e7060b63c924cb077bd5c74"
+"checksum rand 0.3.22 (registry+https://github.com/rust-lang/crates.io-index)" = "15a732abf9d20f0ad8eeb6f909bf6868722d9a06e1e50802b6a70351f40b4eb1"
+"checksum rand 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)" = "8356f47b32624fef5b3301c1be97e5944ecdd595409cc5da11d05f211db6cfbd"
+"checksum winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)" = "92c1eb33641e276cfa214a0522acad57be5c56b10cb348b3c5117db75f3ac4b0"
+"checksum winapi-i686-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6"
+"checksum winapi-x86_64-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f"
diff --git a/guessing-game/Cargo.toml b/guessing-game/Cargo.toml
new file mode 100755
index 0000000..8238fc5
--- /dev/null
+++ b/guessing-game/Cargo.toml
@@ -0,0 +1,8 @@
+[package]
+name = "guessing-game"
+version = "0.1.0"
+authors = ["Adam Carpenter <carpenat@ES.AD.ADP.COM>"]
+edition = "2018"
+
+[dependencies]
+rand = "0.3.14"
diff --git a/guessing-game/src/main.rs b/guessing-game/src/main.rs
new file mode 100755
index 0000000..38dd28d
--- /dev/null
+++ b/guessing-game/src/main.rs
@@ -0,0 +1,36 @@
+use std::io;
+use std::cmp::Ordering;
+use rand::Rng;
+
+fn main() {
+ println!("Guess the number!");
+
+ let secret_number = rand::thread_rng().gen_range(1, 101);
+ //println!("The secret number is: {}", secret_number);
+
+ loop {
+ println!("Enter a guess.");
+
+ let mut guess = String::new();
+
+ io::stdin().read_line(&mut guess)
+ .expect("Failed to read line.");
+
+ let guess: u32 = match guess.trim().parse() {
+ Ok(num) => num,
+ Err(_) => continue,
+ };
+
+ println!("You guessed: {}", guess);
+
+ match guess.cmp(&secret_number) {
+ Ordering::Less => println!("Too small!"),
+ Ordering::Greater => println!("Too big!"),
+ Ordering::Equal => {
+ println!("You win!");
+ break;
+ }
+ }
+ }
+
+}
diff --git a/hello_world/hello_cargo/.gitignore b/hello_world/hello_cargo/.gitignore
new file mode 100755
index 0000000..53eaa21
--- /dev/null
+++ b/hello_world/hello_cargo/.gitignore
@@ -0,0 +1,2 @@
+/target
+**/*.rs.bk
diff --git a/hello_world/hello_cargo/Cargo.lock b/hello_world/hello_cargo/Cargo.lock
new file mode 100755
index 0000000..bd8a836
--- /dev/null
+++ b/hello_world/hello_cargo/Cargo.lock
@@ -0,0 +1,4 @@
+[[package]]
+name = "hello_cargo"
+version = "0.1.0"
+
diff --git a/hello_world/hello_cargo/Cargo.toml b/hello_world/hello_cargo/Cargo.toml
new file mode 100755
index 0000000..61d091a
--- /dev/null
+++ b/hello_world/hello_cargo/Cargo.toml
@@ -0,0 +1,7 @@
+[package]
+name = "hello_cargo"
+version = "0.1.0"
+authors = ["Adam Carpenter <carpenat@ES.AD.ADP.COM>"]
+edition = "2018"
+
+[dependencies]
diff --git a/hello_world/hello_cargo/src/main.rs b/hello_world/hello_cargo/src/main.rs
new file mode 100755
index 0000000..e7a11a9
--- /dev/null
+++ b/hello_world/hello_cargo/src/main.rs
@@ -0,0 +1,3 @@
+fn main() {
+ println!("Hello, world!");
+}
diff --git a/hello_world/main.exe b/hello_world/main.exe
new file mode 100755
index 0000000..8bb285b
--- /dev/null
+++ b/hello_world/main.exe
Binary files differ
diff --git a/hello_world/main.rs b/hello_world/main.rs
new file mode 100755
index 0000000..3d46bbe
--- /dev/null
+++ b/hello_world/main.rs
@@ -0,0 +1,4 @@
+fn main() {
+ println!("hello world!");
+}
+
diff --git a/horcrux/.gitignore b/horcrux/.gitignore
new file mode 100755
index 0000000..53eaa21
--- /dev/null
+++ b/horcrux/.gitignore
@@ -0,0 +1,2 @@
+/target
+**/*.rs.bk
diff --git a/horcrux/Cargo.toml b/horcrux/Cargo.toml
new file mode 100755
index 0000000..f6996ac
--- /dev/null
+++ b/horcrux/Cargo.toml
@@ -0,0 +1,7 @@
+[package]
+name = "horcrux"
+version = "0.1.0"
+authors = ["Adam Carpenter <carpenat@ES.AD.ADP.COM>"]
+edition = "2018"
+
+[dependencies]
diff --git a/horcrux/src/main.rs b/horcrux/src/main.rs
new file mode 100755
index 0000000..e7a11a9
--- /dev/null
+++ b/horcrux/src/main.rs
@@ -0,0 +1,3 @@
+fn main() {
+ println!("Hello, world!");
+}
diff --git a/mathsssss/.gitignore b/mathsssss/.gitignore
new file mode 100644
index 0000000..53eaa21
--- /dev/null
+++ b/mathsssss/.gitignore
@@ -0,0 +1,2 @@
+/target
+**/*.rs.bk
diff --git a/mathsssss/Cargo.lock b/mathsssss/Cargo.lock
new file mode 100644
index 0000000..7ef6f32
--- /dev/null
+++ b/mathsssss/Cargo.lock
@@ -0,0 +1,4 @@
+[[package]]
+name = "mathsssss"
+version = "0.1.0"
+
diff --git a/mathsssss/Cargo.toml b/mathsssss/Cargo.toml
new file mode 100644
index 0000000..201c096
--- /dev/null
+++ b/mathsssss/Cargo.toml
@@ -0,0 +1,7 @@
+[package]
+name = "mathsssss"
+version = "0.1.0"
+authors = ["Adam Carpenter <adam.carpenter@adp.com>"]
+edition = "2018"
+
+[dependencies]
diff --git a/mathsssss/src/main.rs b/mathsssss/src/main.rs
new file mode 100644
index 0000000..991590b
--- /dev/null
+++ b/mathsssss/src/main.rs
@@ -0,0 +1,61 @@
+use std::env;
+use std::collections::HashMap;
+
+fn calc_mean(numbers: &Vec<i32>) -> f32 {
+ let sum: i32 = numbers.iter().sum();
+ sum as f32 / numbers.len() as f32
+}
+
+fn calc_median(numbers: &Vec<i32>) -> i32 {
+ numbers[numbers.len() / 2]
+}
+
+fn calc_mode(numbers: &Vec<i32>) -> i32 {
+ let mut counts: HashMap<i32, i32> = HashMap::new();
+
+ for each in numbers {
+ let count = counts.entry(*each).or_insert(0);
+ *count += 1;
+ }
+
+ let mut most: i32 = 0;
+ let mut result: i32 = 0;
+
+ for (key, val) in counts.iter() {
+
+ if val > &most {
+ most = *val;
+ result = *key;
+ }
+ }
+
+ if most <= 1 {
+ 0
+ }
+ else {
+ result
+ }
+
+}
+
+fn main() {
+ // grab numbers
+ let mut numbers: Vec<i32> = Vec::new();
+
+ for arg in env::args().skip(1) {
+ let number: i32 = arg.trim().parse()
+ .expect("error: could not parse arg");
+ numbers.push(number);
+ }
+
+ // sort list (mostly for median)
+ numbers.sort_by(|a, b| a.partial_cmp(b).unwrap());
+
+ // calculate and print results
+ let mean: f32 = calc_mean(&numbers);
+ println!("mean: {}", mean);
+ let median: i32 = calc_median(&numbers);
+ println!("median: {}", median);
+ let mode: i32 = calc_mode(&numbers);
+ println!("mode: {}", mode);
+}
diff --git a/ownership/.gitignore b/ownership/.gitignore
new file mode 100755
index 0000000..53eaa21
--- /dev/null
+++ b/ownership/.gitignore
@@ -0,0 +1,2 @@
+/target
+**/*.rs.bk
diff --git a/ownership/Cargo.lock b/ownership/Cargo.lock
new file mode 100755
index 0000000..9e4e62d
--- /dev/null
+++ b/ownership/Cargo.lock
@@ -0,0 +1,4 @@
+[[package]]
+name = "ownership"
+version = "0.1.0"
+
diff --git a/ownership/Cargo.toml b/ownership/Cargo.toml
new file mode 100755
index 0000000..f21df45
--- /dev/null
+++ b/ownership/Cargo.toml
@@ -0,0 +1,7 @@
+[package]
+name = "ownership"
+version = "0.1.0"
+authors = ["Adam Carpenter <carpenat@ES.AD.ADP.COM>"]
+edition = "2018"
+
+[dependencies]
diff --git a/ownership/src/main.rs b/ownership/src/main.rs
new file mode 100755
index 0000000..1684f55
--- /dev/null
+++ b/ownership/src/main.rs
@@ -0,0 +1,51 @@
+fn main() {
+ //let words = String::from("hello there world");
+ //let words = "hello there world";
+ //let first = first_word(&words);
+ //let second = second_word(&words);
+ //let last = last_word(&words);
+ //println!("{}\n{}", first, last);
+ let a = [1, 2, 3, 4, 5];
+ let slice = &a[1..4];
+
+ for each in slice {
+ println!("{}", each);
+ }
+}
+
+fn first_word(s: &str) -> &str {
+ let bytes = s.as_bytes();
+
+ for (i, &item) in bytes.iter().enumerate() {
+ if item == b' ' {
+ return &s[..i];
+ }
+ }
+
+ &s
+}
+
+fn second_word(s: &str) -> &str {
+ let bytes = s.as_bytes();
+
+ for (i, &item) in bytes.iter().enumerate() {
+ if item == b' ' {
+ return &s[i + 1..];
+ }
+ }
+
+ &s
+}
+
+fn last_word(s: &str) -> &str {
+ let bytes = s.as_bytes();
+ let mut result = "";
+
+ for (i, &item) in bytes.iter().enumerate() {
+ if item == b' ' {
+ result = &s[i + 1..];
+ }
+ }
+
+ &result
+}
diff --git a/packages/my-project/.gitignore b/packages/my-project/.gitignore
new file mode 100755
index 0000000..53eaa21
--- /dev/null
+++ b/packages/my-project/.gitignore
@@ -0,0 +1,2 @@
+/target
+**/*.rs.bk
diff --git a/packages/my-project/Cargo.lock b/packages/my-project/Cargo.lock
new file mode 100755
index 0000000..9679152
--- /dev/null
+++ b/packages/my-project/Cargo.lock
@@ -0,0 +1,4 @@
+[[package]]
+name = "my-project"
+version = "0.1.0"
+
diff --git a/packages/my-project/Cargo.toml b/packages/my-project/Cargo.toml
new file mode 100755
index 0000000..6edcb51
--- /dev/null
+++ b/packages/my-project/Cargo.toml
@@ -0,0 +1,7 @@
+[package]
+name = "my-project"
+version = "0.1.0"
+authors = ["Adam Carpenter <carpenat@ES.AD.ADP.COM>"]
+edition = "2018"
+
+[dependencies]
diff --git a/packages/my-project/src/main.rs b/packages/my-project/src/main.rs
new file mode 100755
index 0000000..486ae46
--- /dev/null
+++ b/packages/my-project/src/main.rs
@@ -0,0 +1,82 @@
+mod sound;
+
+fn main() {
+ crate::sound::instrument::clarinet();
+ sound::instrument::clarinet();
+}
+//mod sound {
+// pub mod instrument {
+// pub mod woodwind {
+//
+// pub fn clarinet() {
+// println!("clarinet");
+// }
+//
+// }
+//
+// pub mod string {
+//
+// pub fn guitar() {
+// println!("guitar");
+// super::woodwind::clarinet();
+// }
+//
+// }
+//
+// }
+//
+// mod voice {
+// }
+//
+//}
+//
+//mod performance_group {
+// pub use crate::sound::instrument::woodwind;
+//
+// pub fn clarinet_trio() {
+// woodwind::clarinet();
+// woodwind::clarinet();
+// woodwind::clarinet();
+// }
+//
+//}
+//
+//fn main() {
+// performance_group::clarinet_trio();
+// performance_group::woodwind::clarinet();
+//}
+
+//mod plant {
+// pub struct Vegetable {
+// pub name: String,
+// id: i32,
+// }
+//
+// impl Vegetable {
+// pub fn new(name: &str) -> Vegetable {
+// Vegetable {
+// name: String::from(name),
+// id: 1,
+// }
+// }
+// }
+//}
+//
+//fn main() {
+// let mut v = plant::Vegetable::new("squash");
+// v.name = String::from("butternut squash");
+// println!("{} are delicious", v.name);
+// //println!("The id is: {}", v.id);
+//}
+
+//mod menu {
+// pub enum Appetizer {
+// Soup,
+// Salad,
+// }
+//}
+//
+//fn main() {
+// let order1 = menu::Appetizer::Soup;
+// let order2 = menu::Appetizer::Salad;
+//}
diff --git a/packages/my-project/src/sound.rs b/packages/my-project/src/sound.rs
new file mode 100755
index 0000000..866ac56
--- /dev/null
+++ b/packages/my-project/src/sound.rs
@@ -0,0 +1 @@
+pub mod instrument;
diff --git a/packages/my-project/src/sound/instrument.rs b/packages/my-project/src/sound/instrument.rs
new file mode 100755
index 0000000..727784e
--- /dev/null
+++ b/packages/my-project/src/sound/instrument.rs
@@ -0,0 +1,3 @@
+pub fn clarinet() {
+ println!("clarinet");
+}
diff --git a/piglatin/.gitignore b/piglatin/.gitignore
new file mode 100644
index 0000000..53eaa21
--- /dev/null
+++ b/piglatin/.gitignore
@@ -0,0 +1,2 @@
+/target
+**/*.rs.bk
diff --git a/piglatin/Cargo.lock b/piglatin/Cargo.lock
new file mode 100644
index 0000000..67b9b02
--- /dev/null
+++ b/piglatin/Cargo.lock
@@ -0,0 +1,4 @@
+[[package]]
+name = "piglatin"
+version = "0.1.0"
+
diff --git a/piglatin/Cargo.toml b/piglatin/Cargo.toml
new file mode 100644
index 0000000..7d62333
--- /dev/null
+++ b/piglatin/Cargo.toml
@@ -0,0 +1,7 @@
+[package]
+name = "piglatin"
+version = "0.1.0"
+authors = ["Adam Carpenter <adam.carpenter@adp.com>"]
+edition = "2018"
+
+[dependencies]
diff --git a/piglatin/src/main.rs b/piglatin/src/main.rs
new file mode 100644
index 0000000..c5d9813
--- /dev/null
+++ b/piglatin/src/main.rs
@@ -0,0 +1,38 @@
+use std::env;
+
+fn print_usage() {
+ eprintln!("error: usage: piglatin [word] [words]...");
+}
+
+fn main() {
+
+ for mut word in env::args().skip(1) {
+ // grab first letter
+ let first = match word.get(0..1) {
+ Some(s) => s,
+ None => {
+ print_usage();
+ return;
+ }
+ };
+
+ // check if first letter is vowel or consonant
+ // if vowel, append -hay and print
+ // if consonant, appent first letter and -ay and print
+ match first {
+ "a" | "e" | "i" | "o" | "u" |
+ "A" | "E" | "I" | "O" | "U" => {
+ print!("{}-hay ", word);
+ },
+ _ => {
+ let rest = match word.get(1..) {
+ Some(s) => s,
+ None => "",
+ };
+ print!("{}-{}ay ", rest, first);
+ },
+ }
+ }
+
+ println!();
+}
diff --git a/rust-csci415 b/rust-csci415
new file mode 160000
+Subproject eb478e1594d45a0a73a634a0b3b013d7799b17c
diff --git a/structs/.gitignore b/structs/.gitignore
new file mode 100755
index 0000000..53eaa21
--- /dev/null
+++ b/structs/.gitignore
@@ -0,0 +1,2 @@
+/target
+**/*.rs.bk
diff --git a/structs/Cargo.lock b/structs/Cargo.lock
new file mode 100755
index 0000000..25b0b72
--- /dev/null
+++ b/structs/Cargo.lock
@@ -0,0 +1,4 @@
+[[package]]
+name = "structs"
+version = "0.1.0"
+
diff --git a/structs/Cargo.toml b/structs/Cargo.toml
new file mode 100755
index 0000000..e61ea2a
--- /dev/null
+++ b/structs/Cargo.toml
@@ -0,0 +1,7 @@
+[package]
+name = "structs"
+version = "0.1.0"
+authors = ["Adam Carpenter <carpenat@ES.AD.ADP.COM>"]
+edition = "2018"
+
+[dependencies]
diff --git a/structs/src/main.rs b/structs/src/main.rs
new file mode 100755
index 0000000..cf93866
--- /dev/null
+++ b/structs/src/main.rs
@@ -0,0 +1,32 @@
+#[derive(Debug)]
+struct Rectangle {
+ width: u32,
+ height: u32,
+}
+
+impl Rectangle {
+
+ fn area(&self) -> u32 {
+ self.width * self.height
+ }
+
+ fn can_hold(&self, other: &Rectangle ) -> bool {
+ self.width > other.width && self.height > other.height
+ }
+
+}
+
+fn main() {
+ let rect1 = Rectangle {
+ width: 30,
+ height: 50,
+ };
+ let rect2 = Rectangle {
+ width: 3,
+ height: 5,
+ };
+ println!("{:#?}", rect1);
+ println!("The area of the rectangle is {} square pixels.", rect1.area());
+ println!("{}", rect1.can_hold(&rect2));
+}
+
diff --git a/structs/src/main.rs.bak b/structs/src/main.rs.bak
new file mode 100755
index 0000000..361b225
--- /dev/null
+++ b/structs/src/main.rs.bak
@@ -0,0 +1,36 @@
+struct User {
+ username: String,
+ email: String,
+ sign_in_count: u64,
+ active: bool,
+}
+
+fn main() {
+// let mut user1 = User {
+// email: String::from("test@tester.net"),
+// username: String::from("testytester"),
+// active: true,
+// sign_in_count: 999,
+// };
+// let user1 = build_user(String::from("dennis.nedry@adp.com"), String::from("nedryland"));
+// let user2 = User {
+// email: String::from("john.hammond@adp.com"),
+// username: String::from("spare_no_expense"),
+// ..user1
+// };
+// println!("{} {} {} {}", user2.email, user2.username, user2.active, user2.sign_in_count);
+
+ struct Color(u32, u32, u32);
+ struct Point(i32, i32, i32);
+ let black = Color(0, 0, 0);
+ let origin = Point(0, -1, 0);
+}
+
+fn build_user(email: String, username: String) -> User {
+ User {
+ email,
+ username,
+ active: true,
+ sign_in_count: 1,
+ }
+}
diff --git a/traits/.gitignore b/traits/.gitignore
new file mode 100644
index 0000000..53eaa21
--- /dev/null
+++ b/traits/.gitignore
@@ -0,0 +1,2 @@
+/target
+**/*.rs.bk
diff --git a/traits/Cargo.lock b/traits/Cargo.lock
new file mode 100644
index 0000000..3eff52b
--- /dev/null
+++ b/traits/Cargo.lock
@@ -0,0 +1,4 @@
+[[package]]
+name = "traits"
+version = "0.1.0"
+
diff --git a/traits/Cargo.toml b/traits/Cargo.toml
new file mode 100644
index 0000000..461bdcd
--- /dev/null
+++ b/traits/Cargo.toml
@@ -0,0 +1,7 @@
+[package]
+name = "traits"
+version = "0.1.0"
+authors = ["Adam Carpenter <adam.carpenter@adp.com>"]
+edition = "2018"
+
+[dependencies]
diff --git a/traits/src/main.rs b/traits/src/main.rs
new file mode 100644
index 0000000..770caa9
--- /dev/null
+++ b/traits/src/main.rs
@@ -0,0 +1,114 @@
+use std::fmt::Display;
+
+struct Pair<T> {
+ x: T,
+ y: T,
+}
+
+impl<T> Pair<T> {
+ fn new(x: T, y: T) -> Self {
+ Self {
+ x,
+ y,
+ }
+ }
+}
+
+impl<T: Display + PartialOrd> Pair<T> {
+ fn cmp_display(&self) {
+ if self.x >= self.y {
+ println!("{}", self.x);
+ }
+ else {
+ println!("{}", self.y);
+ }
+ }
+}
+
+pub trait Summary {
+ fn summarize(&self) -> String {
+ format!("(read more from {}...)", self.summarize_author())
+ }
+
+ fn summarize_author(&self) -> String;
+}
+
+pub struct NewsArticle {
+ pub headline: String,
+ pub location: String,
+ pub author: String,
+ pub content: String,
+}
+
+impl Summary for NewsArticle {
+// fn summarize(&self) -> String {
+// format!("{}, by {} ({})", self.headline, self.author, self.location)
+// }
+
+ fn summarize_author(&self) -> String {
+ format!("{}", self.author)
+ }
+
+}
+
+pub struct Tweet {
+ pub username: String,
+ pub content: String,
+ pub reply: bool,
+ pub retweet: bool,
+}
+
+impl Summary for Tweet {
+// fn summarize(&self) -> String {
+// format!("{}: {}", self.username, self.content)
+// }
+
+ fn summarize_author(&self) -> String {
+ format!("@{}", self.username)
+ }
+}
+
+pub fn notify(item: impl Summary) {
+ println!("breaking news: {}", item.summarize());
+}
+
+fn returns_summarizable() -> impl Summary {
+
+ NewsArticle {
+ headline: String::from("Penguins win the stanley cup championship!"),
+ location: String::from("Pittsburgh, PA, USA"),
+ author: String::from("Iceburgh"),
+ content: String::from("The pittsburgh penguins are winners I guess."),
+ }
+// Tweet {
+// username: String::from("horse_ebooks"),
+// content: String::from("of course blargh"),
+// reply: false,
+// retweet: false,
+// }
+}
+
+fn main() {
+
+ let tweet = Tweet {
+ username: String::from("horse_ebooks"),
+ content: String::from("of course, as you probably already know, people"),
+ reply: false,
+ retweet: false,
+ };
+
+ //dbg!(tweet.summarize());
+
+ let article = NewsArticle {
+ headline: String::from("Penguins win the stanley cup championship!"),
+ location: String::from("Pittsburgh, PA, USA"),
+ author: String::from("Iceburgh"),
+ content: String::from("The pittsburgh penguins are winners I guess."),
+ };
+
+ //dbg!(article.summarize());
+
+ //notify(tweet);
+
+ returns_summarizable();
+}
diff --git a/variables/.gitignore b/variables/.gitignore
new file mode 100755
index 0000000..53eaa21
--- /dev/null
+++ b/variables/.gitignore
@@ -0,0 +1,2 @@
+/target
+**/*.rs.bk
diff --git a/variables/Cargo.lock b/variables/Cargo.lock
new file mode 100755
index 0000000..6d77f6b
--- /dev/null
+++ b/variables/Cargo.lock
@@ -0,0 +1,4 @@
+[[package]]
+name = "variables"
+version = "0.1.0"
+
diff --git a/variables/Cargo.toml b/variables/Cargo.toml
new file mode 100755
index 0000000..62ee489
--- /dev/null
+++ b/variables/Cargo.toml
@@ -0,0 +1,7 @@
+[package]
+name = "variables"
+version = "0.1.0"
+authors = ["Adam Carpenter <carpenat@ES.AD.ADP.COM>"]
+edition = "2018"
+
+[dependencies]
diff --git a/variables/src/main.rs b/variables/src/main.rs
new file mode 100755
index 0000000..d632530
--- /dev/null
+++ b/variables/src/main.rs
@@ -0,0 +1,6 @@
+fn main() {
+ let a: [i32; 5] = [1, 2, 3, 4, 5];
+ let first = a[0];
+ let second = a[1];
+ println!("{} {}", first, second);
+}
diff --git a/xmas/.gitignore b/xmas/.gitignore
new file mode 100644
index 0000000..53eaa21
--- /dev/null
+++ b/xmas/.gitignore
@@ -0,0 +1,2 @@
+/target
+**/*.rs.bk
diff --git a/xmas/Cargo.lock b/xmas/Cargo.lock
new file mode 100644
index 0000000..033bd72
--- /dev/null
+++ b/xmas/Cargo.lock
@@ -0,0 +1,4 @@
+[[package]]
+name = "xmas"
+version = "0.1.0"
+
diff --git a/xmas/Cargo.toml b/xmas/Cargo.toml
new file mode 100644
index 0000000..d10c790
--- /dev/null
+++ b/xmas/Cargo.toml
@@ -0,0 +1,7 @@
+[package]
+name = "xmas"
+version = "0.1.0"
+authors = ["Adam Carpenter <adam.carpenter@adp.com>"]
+edition = "2018"
+
+[dependencies]
diff --git a/xmas/out.txt b/xmas/out.txt
new file mode 100644
index 0000000..55ae012
--- /dev/null
+++ b/xmas/out.txt
@@ -0,0 +1,114 @@
+
+On the 1st day of Christmas,
+My true love gave to me
+A partridge in a pear tree
+
+On the 2nd day of Christmas,
+My true love gave to me
+Two turtle doves and
+A partridge in a pear tree
+
+On the 3rd day of Christmas,
+My true love gave to me
+Three French hens
+Two turtle doves and
+A partridge in a pear tree
+
+On the 4th day of Christmas,
+My true love gave to me
+Four calling birds
+Three French hens
+Two turtle doves and
+A partridge in a pear tree
+
+On the 5th day of Christmas,
+My true love gave to me
+Five golden rings
+Four calling birds
+Three French hens
+Two turtle doves and
+A partridge in a pear tree
+
+On the 6th day of Christmas,
+My true love gave to me
+Six geese a-laying
+Five golden rings
+Four calling birds
+Three French hens
+Two turtle doves and
+A partridge in a pear tree
+
+On the 7th day of Christmas,
+My true love gave to me
+Seven swans a-swimming
+Six geese a-laying
+Five golden rings
+Four calling birds
+Three French hens
+Two turtle doves and
+A partridge in a pear tree
+
+On the 8th day of Christmas,
+My true love gave to me
+Eight maids a-milking
+Seven swans a-swimming
+Six geese a-laying
+Five golden rings
+Four calling birds
+Three French hens
+Two turtle doves and
+A partridge in a pear tree
+
+On the 9th day of Christmas,
+My true love gave to me
+Nine ladies dancing
+Eight maids a-milking
+Seven swans a-swimming
+Six geese a-laying
+Five golden rings
+Four calling birds
+Three French hens
+Two turtle doves and
+A partridge in a pear tree
+
+On the 10th day of Christmas,
+My true love gave to me
+Ten lords a-leaping
+Nine ladies dancing
+Eight maids a-milking
+Seven swans a-swimming
+Six geese a-laying
+Five golden rings
+Four calling birds
+Three French hens
+Two turtle doves and
+A partridge in a pear tree
+
+On the 11th day of Christmas,
+My true love gave to me
+Eleven pipers piping
+Ten lords a-leaping
+Nine ladies dancing
+Eight maids a-milking
+Seven swans a-swimming
+Six geese a-laying
+Five golden rings
+Four calling birds
+Three French hens
+Two turtle doves and
+A partridge in a pear tree
+
+On the 12th day of Christmas,
+My true love gave to me
+Twelve drummers drumming
+Eleven pipers piping
+Ten lords a-leaping
+Nine ladies dancing
+Eight maids a-milking
+Seven swans a-swimming
+Six geese a-laying
+Five golden rings
+Four calling birds
+Three French hens
+Two turtle doves and
+A partridge in a pear tree
diff --git a/xmas/src/main.rs b/xmas/src/main.rs
new file mode 100644
index 0000000..e725a26
--- /dev/null
+++ b/xmas/src/main.rs
@@ -0,0 +1,42 @@
+fn main() {
+ let days = [
+ "1st",
+ "2nd",
+ "3rd",
+ "4th",
+ "5th",
+ "6th",
+ "7th",
+ "8th",
+ "9th",
+ "10th",
+ "11th",
+ "12th",
+ ];
+ let gifts = [
+ "A partridge in a pear tree",
+ "Two turtle doves and",
+ "Three French hens",
+ "Four calling birds",
+ "Five golden rings",
+ "Six geese a-laying",
+ "Seven swans a-swimming",
+ "Eight maids a-milking",
+ "Nine ladies dancing",
+ "Ten lords a-leaping",
+ "Eleven pipers piping",
+ "Twelve drummers drumming",
+ ];
+
+ // for each day
+ for mut each in 0..12 {
+ println!("\nOn the {} day of Christmas,", days[each]);
+ println!("My true love gave to me");
+
+ // print associated lyrics
+ for i in (0..each+1).rev() {
+ println!("{}", gifts[i]);
+ }
+
+ }
+}