summaryrefslogtreecommitdiff
path: root/structs/src/main.rs
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 /structs/src/main.rs
parente25482fca375d318a39c3b54db396b0db6e0b263 (diff)
downloadlearning-rust-67cdcc2e12118becb823e20a40cc2687f2b8425a.tar.xz
learning-rust-67cdcc2e12118becb823e20a40cc2687f2b8425a.zip
Started Rust in Action MEAP.
Diffstat (limited to 'structs/src/main.rs')
-rwxr-xr-xstructs/src/main.rs32
1 files changed, 0 insertions, 32 deletions
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));
-}
-