From 29f0bb891aa34ce0ea6bfc6bf6b1d3dc61c3c0f5 Mon Sep 17 00:00:00 2001 From: laurens Date: Fri, 22 May 2020 13:54:46 +0200 Subject: [PATCH] rectangles with tuples --- rectangles/src/main.rs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/rectangles/src/main.rs b/rectangles/src/main.rs index 506fa3d..b6b4fe1 100644 --- a/rectangles/src/main.rs +++ b/rectangles/src/main.rs @@ -6,8 +6,19 @@ fn main() { "The area of the rectangle is {} square pixels.", area(width1, height1) ); + + let rect = (30, 50); + + println!( + "The area of the rectangle is {} square pixels.", + area_tuple(rect) + ); } fn area(width: u32, height: u32) -> u32 { width * height } + +fn area_tuple(dimensions: (u32, u32)) -> u32 { + dimensions.0 * dimensions.1 +}