2024-11-12 07:51:40 +00:00
|
|
|
struct Rectangle {
|
|
|
|
width: u32,
|
|
|
|
height: u32,
|
|
|
|
}
|
|
|
|
|
2024-11-12 07:46:32 +00:00
|
|
|
fn main() {
|
2024-11-12 07:51:40 +00:00
|
|
|
let rect1 = Rectangle {
|
|
|
|
width: 30,
|
|
|
|
height: 50,
|
|
|
|
};
|
2024-11-12 07:46:32 +00:00
|
|
|
|
|
|
|
println!(
|
|
|
|
"The area of the rectangle is {} square pixels.",
|
2024-11-12 07:51:40 +00:00
|
|
|
area(&rect1)
|
2024-11-12 07:46:32 +00:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2024-11-12 07:51:40 +00:00
|
|
|
fn area(rectangle: &Rectangle) -> u32 {
|
|
|
|
rectangle.width * rectangle.height
|
2024-11-12 07:46:32 +00:00
|
|
|
}
|