summaryrefslogtreecommitdiff
path: root/examples/02-sum/output/rust/src/main.rs
diff options
context:
space:
mode:
Diffstat (limited to 'examples/02-sum/output/rust/src/main.rs')
-rw-r--r--examples/02-sum/output/rust/src/main.rs16
1 files changed, 16 insertions, 0 deletions
diff --git a/examples/02-sum/output/rust/src/main.rs b/examples/02-sum/output/rust/src/main.rs
new file mode 100644
index 0000000..010ea2a
--- /dev/null
+++ b/examples/02-sum/output/rust/src/main.rs
@@ -0,0 +1,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 })
+}