Add code for printing the details of the rectangle
This commit is contained in:
parent
72cd4da20e
commit
2b3f04ce4c
1 changed files with 2 additions and 8 deletions
|
@ -1,3 +1,4 @@
|
||||||
|
#[derive(Debug)]
|
||||||
struct Rectangle {
|
struct Rectangle {
|
||||||
width: u32,
|
width: u32,
|
||||||
height: u32,
|
height: u32,
|
||||||
|
@ -9,12 +10,5 @@ fn main() {
|
||||||
height: 50,
|
height: 50,
|
||||||
};
|
};
|
||||||
|
|
||||||
println!(
|
println!("rect1 is {rect1:?}");
|
||||||
"The area of the rectangle is {} square pixels.",
|
|
||||||
area(&rect1)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
fn area(rectangle: &Rectangle) -> u32 {
|
|
||||||
rectangle.width * rectangle.height
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue