rectangles with tuples
This commit is contained in:
parent
53705f42a4
commit
29f0bb891a
1 changed files with 11 additions and 0 deletions
|
|
@ -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
|
||||||
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue