Add code for printing the details of the rectangle

This commit is contained in:
Manuel Thalmann 2024-11-25 23:59:14 +01:00
parent 72cd4da20e
commit 2b3f04ce4c

View file

@ -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:?}");
}