aboutsummaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorMichael Williamson <mike@zwobble.org>2023-09-28 15:44:28 +0100
committerMichael Williamson <mike@zwobble.org>2023-09-28 15:44:28 +0100
commitecb878e11effdfd91ed1c29f18913e7074a527e4 (patch)
treefd368fdfa4940544492de9351fcd6d623f338fa1 /examples
parent12bc0b647eb6276a93c134e35c5babc4efc01d93 (diff)
Hoist structs
Diffstat (limited to 'examples')
-rw-r--r--examples/15-struct-hoisting/shed.toml9
-rw-r--r--examples/15-struct-hoisting/src/HelloWorld.shed12
2 files changed, 21 insertions, 0 deletions
diff --git a/examples/15-struct-hoisting/shed.toml b/examples/15-struct-hoisting/shed.toml
new file mode 100644
index 00000000..156fa7c6
--- /dev/null
+++ b/examples/15-struct-hoisting/shed.toml
@@ -0,0 +1,9 @@
+[shed]
+main = "HelloWorld"
+
+[[shed.bins]]
+name = "hello-world"
+
+[[shed.examples]]
+bin = "hello-world"
+expected-output = "hello, world"
diff --git a/examples/15-struct-hoisting/src/HelloWorld.shed b/examples/15-struct-hoisting/src/HelloWorld.shed
new file mode 100644
index 00000000..d9caa802
--- /dev/null
+++ b/examples/15-struct-hoisting/src/HelloWorld.shed
@@ -0,0 +1,12 @@
+val messageParts = MessageParts(.part1 = "hello, ", .part2 = "world\n");
+
+fun main() ! Io -> Unit {
+ print!(messageParts.part1);
+ print!(messageParts.part2);
+}
+
+struct MessageParts(
+ .part1: String,
+ .part2: String,
+) {
+}