Refactor rectangles
to use tuples
This commit is contained in:
parent
41fde7bef9
commit
1fbb0d803b
1 changed files with 4 additions and 5 deletions
|
@ -1,13 +1,12 @@
|
||||||
fn main() {
|
fn main() {
|
||||||
let width1 = 30;
|
let rect1 = (30, 50);
|
||||||
let height1 = 50;
|
|
||||||
|
|
||||||
println!(
|
println!(
|
||||||
"The area of the rectangle is {} square pixels.",
|
"The area of the rectangle is {} square pixels.",
|
||||||
area(width1, height1)
|
area(rect1)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn area(width: u32, height: u32) -> u32 {
|
fn area(dimensions: (u32, u32)) -> u32 {
|
||||||
width * height
|
dimensions.0 * dimensions.1
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue