diff --git a/rectangles/src/main.rs b/rectangles/src/main.rs index a1cae3e..7fbbbd0 100644 --- a/rectangles/src/main.rs +++ b/rectangles/src/main.rs @@ -8,6 +8,10 @@ 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() { @@ -40,6 +44,12 @@ fn main() { "The area of the rectangle is {} square pixels.", rect.area() ); + + println!( + "The rectangle {:#?} can hold itself obviously: {}.", + rect, + rect.can_hold(&rect), + ); } fn area(width: u32, height: u32) -> u32 {