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 {
|
||||
width: u32,
|
||||
height: u32,
|
||||
|
@ -9,12 +10,5 @@ fn main() {
|
|||
height: 50,
|
||||
};
|
||||
|
||||
println!(
|
||||
"The area of the rectangle is {} square pixels.",
|
||||
area(&rect1)
|
||||
);
|
||||
}
|
||||
|
||||
fn area(rectangle: &Rectangle) -> u32 {
|
||||
rectangle.width * rectangle.height
|
||||
println!("rect1 is {rect1:?}");
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue