diff options
author | Adam Carpenter <53hornet@gmail.com> | 2019-03-27 15:32:37 -0400 |
---|---|---|
committer | Adam Carpenter <53hornet@gmail.com> | 2019-03-27 15:32:37 -0400 |
commit | 67cdcc2e12118becb823e20a40cc2687f2b8425a (patch) | |
tree | ed92c3234b89079e6d4cf36f5e80c5ffa79def48 /structs | |
parent | e25482fca375d318a39c3b54db396b0db6e0b263 (diff) | |
download | learning-rust-67cdcc2e12118becb823e20a40cc2687f2b8425a.tar.xz learning-rust-67cdcc2e12118becb823e20a40cc2687f2b8425a.zip |
Started Rust in Action MEAP.
Diffstat (limited to 'structs')
-rwxr-xr-x | structs/Cargo.lock | 4 | ||||
-rwxr-xr-x | structs/Cargo.toml | 7 | ||||
-rwxr-xr-x | structs/src/main.rs | 32 | ||||
-rwxr-xr-x | structs/src/main.rs.bak | 36 |
4 files changed, 0 insertions, 79 deletions
diff --git a/structs/Cargo.lock b/structs/Cargo.lock deleted file mode 100755 index 25b0b72..0000000 --- a/structs/Cargo.lock +++ /dev/null @@ -1,4 +0,0 @@ -[[package]] -name = "structs" -version = "0.1.0" - diff --git a/structs/Cargo.toml b/structs/Cargo.toml deleted file mode 100755 index e61ea2a..0000000 --- a/structs/Cargo.toml +++ /dev/null @@ -1,7 +0,0 @@ -[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 deleted file mode 100755 index cf93866..0000000 --- a/structs/src/main.rs +++ /dev/null @@ -1,32 +0,0 @@ -#[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 deleted file mode 100755 index 361b225..0000000 --- a/structs/src/main.rs.bak +++ /dev/null @@ -1,36 +0,0 @@ -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, - } -} |