summaryrefslogtreecommitdiff
path: root/functions/src
diff options
context:
space:
mode:
authorJordan Gong <jordan.gong@protonmail.com>2020-08-10 21:35:16 +0800
committerJordan Gong <jordan.gong@protonmail.com>2020-08-10 21:35:16 +0800
commit2dea1b048e0637346956b979f902dca88c48b616 (patch)
treef4ee1ae5e55adc4f1fc8036af8d03ee89358475f /functions/src
parent6e4f0b4c6d7f7ad0eaaae5f4f2e2f3a08881ee35 (diff)
Functions for fun
Diffstat (limited to 'functions/src')
-rw-r--r--functions/src/main.rs28
1 files changed, 28 insertions, 0 deletions
diff --git a/functions/src/main.rs b/functions/src/main.rs
new file mode 100644
index 0000000..c7a0db1
--- /dev/null
+++ b/functions/src/main.rs
@@ -0,0 +1,28 @@
+fn main() {
+ /* basic */
+ println!("Hello, world!");
+
+ another_function(5, 6);
+
+ /* expression */
+ let y = {
+ let x = 3;
+ x + 1
+ };
+
+ println!("The value of y is: {}", y);
+
+ /* return */
+ let x = plus_one(5);
+
+ println!("The value of x is: {}", x);
+}
+
+fn another_function(x: i32, y:i32) {
+ println!("The value of x is: {}", x);
+ println!("The value of y is: {}", y);
+}
+
+fn plus_one(x: i32) -> i32 {
+ x + 1
+}