summaryrefslogtreecommitdiff
path: root/examples/02-sum/output/rust
diff options
context:
space:
mode:
Diffstat (limited to 'examples/02-sum/output/rust')
-rw-r--r--examples/02-sum/output/rust/.gitignore1
-rw-r--r--examples/02-sum/output/rust/Cargo.lock7
-rw-r--r--examples/02-sum/output/rust/Cargo.toml6
-rw-r--r--examples/02-sum/output/rust/rust-toolchain.toml2
-rw-r--r--examples/02-sum/output/rust/src/main.rs16
-rw-r--r--examples/02-sum/output/rust/src/shapes.rs15
6 files changed, 47 insertions, 0 deletions
diff --git a/examples/02-sum/output/rust/.gitignore b/examples/02-sum/output/rust/.gitignore
new file mode 100644
index 0000000..ea8c4bf
--- /dev/null
+++ b/examples/02-sum/output/rust/.gitignore
@@ -0,0 +1 @@
+/target
diff --git a/examples/02-sum/output/rust/Cargo.lock b/examples/02-sum/output/rust/Cargo.lock
new file mode 100644
index 0000000..9dc6e3e
--- /dev/null
+++ b/examples/02-sum/output/rust/Cargo.lock
@@ -0,0 +1,7 @@
+# This file is automatically @generated by Cargo.
+# It is not intended for manual editing.
+version = 4
+
+[[package]]
+name = "example"
+version = "0.1.0"
diff --git a/examples/02-sum/output/rust/Cargo.toml b/examples/02-sum/output/rust/Cargo.toml
new file mode 100644
index 0000000..5d4c622
--- /dev/null
+++ b/examples/02-sum/output/rust/Cargo.toml
@@ -0,0 +1,6 @@
+[package]
+name = "example"
+version = "0.1.0"
+edition = "2024"
+
+[dependencies]
diff --git a/examples/02-sum/output/rust/rust-toolchain.toml b/examples/02-sum/output/rust/rust-toolchain.toml
new file mode 100644
index 0000000..4fedb95
--- /dev/null
+++ b/examples/02-sum/output/rust/rust-toolchain.toml
@@ -0,0 +1,2 @@
+[toolchain]
+channel = "1.96"
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 })
+}
diff --git a/examples/02-sum/output/rust/src/shapes.rs b/examples/02-sum/output/rust/src/shapes.rs
new file mode 100644
index 0000000..9bb32f4
--- /dev/null
+++ b/examples/02-sum/output/rust/src/shapes.rs
@@ -0,0 +1,15 @@
+/// A 2D shape.
+pub enum Shape {
+ Rectangle(crate::shapes::Rectangle),
+ Triangle(crate::shapes::Triangle),
+}
+
+pub struct Rectangle {
+ pub width: i32,
+ pub height: i32,
+}
+
+pub struct Triangle {
+ pub width: i32,
+ pub height: i32,
+}