面试题答案
一键面试struct Point {
x: f64,
y: f64,
}
struct Rectangle {
top_left: Point,
bottom_right: Point,
}
fn calculate_area(rect: &Rectangle) -> f64 {
let width = rect.bottom_right.x - rect.top_left.x;
let height = rect.top_left.y - rect.bottom_right.y;
width * height
}