rectangles with tuples

This commit is contained in:
laurens 2020-05-22 13:54:46 +02:00
parent 53705f42a4
commit 29f0bb891a

View file

@ -6,8 +6,19 @@ fn main() {
"The area of the rectangle is {} square pixels.", "The area of the rectangle is {} square pixels.",
area(width1, height1) 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 { fn area(width: u32, height: u32) -> u32 {
width * height width * height
} }
fn area_tuple(dimensions: (u32, u32)) -> u32 {
dimensions.0 * dimensions.1
}