From 4c4ddf0e32a817cd1e6b14a72e5ba4f28eb667a0 Mon Sep 17 00:00:00 2001 From: euledge Date: Wed, 13 Feb 2019 00:31:03 +0900 Subject: [PATCH] 3.3 function #6 --- Chapter3.3/functions/Cargo.toml | 7 +++++++ Chapter3.3/functions/src/main.rs | 28 ++++++++++++++++++++++++++++ 2 files changed, 35 insertions(+) create mode 100644 Chapter3.3/functions/Cargo.toml create mode 100644 Chapter3.3/functions/src/main.rs diff --git a/Chapter3.3/functions/Cargo.toml b/Chapter3.3/functions/Cargo.toml new file mode 100644 index 0000000..47430a0 --- /dev/null +++ b/Chapter3.3/functions/Cargo.toml @@ -0,0 +1,7 @@ +[package] +name = "functions" +version = "0.1.0" +authors = ["euledge "] +edition = "2018" + +[dependencies] diff --git a/Chapter3.3/functions/src/main.rs b/Chapter3.3/functions/src/main.rs new file mode 100644 index 0000000..3ac9fdb --- /dev/null +++ b/Chapter3.3/functions/src/main.rs @@ -0,0 +1,28 @@ +fn main() { + println!("Hello, world!"); + + another_function(5, 6); + another_function2(); + + let x = five(); + 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 another_function2() { + let x = 5; + + let y = { + let x = 3; + x + 1 + }; + println!("The value of y is: {}", y); +} + +fn five() -> i32 { + 5 +} \ No newline at end of file