summaryrefslogtreecommitdiff
path: root/generics
diff options
context:
space:
mode:
authorAdam Carpenter <53hornet@gmail.com>2019-03-27 15:32:37 -0400
committerAdam Carpenter <53hornet@gmail.com>2019-03-27 15:32:37 -0400
commit67cdcc2e12118becb823e20a40cc2687f2b8425a (patch)
treeed92c3234b89079e6d4cf36f5e80c5ffa79def48 /generics
parente25482fca375d318a39c3b54db396b0db6e0b263 (diff)
downloadlearning-rust-67cdcc2e12118becb823e20a40cc2687f2b8425a.tar.xz
learning-rust-67cdcc2e12118becb823e20a40cc2687f2b8425a.zip
Started Rust in Action MEAP.
Diffstat (limited to 'generics')
-rw-r--r--generics/Cargo.lock4
-rw-r--r--generics/Cargo.toml7
-rw-r--r--generics/src/main.rs68
3 files changed, 0 insertions, 79 deletions
diff --git a/generics/Cargo.lock b/generics/Cargo.lock
deleted file mode 100644
index 3ddbc8c..0000000
--- a/generics/Cargo.lock
+++ /dev/null
@@ -1,4 +0,0 @@
-[[package]]
-name = "generics"
-version = "0.1.0"
-
diff --git a/generics/Cargo.toml b/generics/Cargo.toml
deleted file mode 100644
index 5529f73..0000000
--- a/generics/Cargo.toml
+++ /dev/null
@@ -1,7 +0,0 @@
-[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
deleted file mode 100644
index e41d6f5..0000000
--- a/generics/src/main.rs
+++ /dev/null
@@ -1,68 +0,0 @@
-//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);
-}