summaryrefslogtreecommitdiff
path: root/examples/02-sum/output/rust/src/main.rs
blob: 010ea2a34313e47bc41c176bfe637773c3ffdab6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
mod shapes;

use shapes::{Rectangle, Shape, Triangle};

fn main() {
    let shape = create_shape();

    let area = match shape {
        Shape::Rectangle(rectangle) => rectangle.width * rectangle.height,
        Shape::Triangle(triangle) => triangle.width * triangle.height / 2,
    };
}

fn create_shape() -> Shape {
    Shape::Rectangle(Rectangle { width: 10, height: 25 })
}