trait Plane {
    fn calc_area(&self) -> f64;
}

struct Triangle {
    base: f64,
    height: f64,
}

struct Trapezoid {
    top_base: f64,
    bottom_base: f64,
    height: f64,
}

impl Plane for Triangle {
    fn calc_area(&self) -> f64 {
        (self.base * self.height) / 2.0
    }
}

impl Plane for Trapezoid {
    fn calc_area(&self) -> f64 {
        (self.top_base + self.bottom_base) * self.height / 2.0
    }
}

fn display_area(plane: &impl Plane) {
    println!("Area: {}", plane.calc_area());
}

fn get_and_display_area(plane: &impl Plane) -> &impl Plane {
    println!("Area: {}", plane.calc_area());
    plane
}

fn main() {
    let triangle = Triangle {base: 10.0, height: 20.0};
    let trapezoid = Trapezoid {top_base: 10.0, bottom_base: 20.0, height: 10.0};
    display_area(&triangle);
    display_area(&trapezoid);
}
