From f28d70b9b85f84d0d841b6b04d44a92b5c7009ea Mon Sep 17 00:00:00 2001 From: NullBite Date: Sun, 1 Oct 2023 20:35:50 -0400 Subject: [PATCH] Add new projects --- functions/Cargo.lock | 7 +++++++ functions/Cargo.toml | 8 ++++++++ functions/src/main.rs | 11 +++++++++++ variables/Cargo.lock | 7 +++++++ variables/Cargo.toml | 8 ++++++++ variables/src/main.rs | 11 +++++++++++ 6 files changed, 52 insertions(+) create mode 100644 functions/Cargo.lock create mode 100644 functions/Cargo.toml create mode 100644 functions/src/main.rs create mode 100644 variables/Cargo.lock create mode 100644 variables/Cargo.toml create mode 100644 variables/src/main.rs diff --git a/functions/Cargo.lock b/functions/Cargo.lock new file mode 100644 index 0000000..82f83a1 --- /dev/null +++ b/functions/Cargo.lock @@ -0,0 +1,7 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 3 + +[[package]] +name = "functions" +version = "0.1.0" diff --git a/functions/Cargo.toml b/functions/Cargo.toml new file mode 100644 index 0000000..a9b5578 --- /dev/null +++ b/functions/Cargo.toml @@ -0,0 +1,8 @@ +[package] +name = "functions" +version = "0.1.0" +edition = "2021" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] diff --git a/functions/src/main.rs b/functions/src/main.rs new file mode 100644 index 0000000..11e917e --- /dev/null +++ b/functions/src/main.rs @@ -0,0 +1,11 @@ +fn main() { + print_labeled_measurement(37, 'h'); +} + +fn another_function(x: i32) { + println!("The value of x is: {x}"); +} + +fn print_labeled_measurement(value: i32, unit_label: char) { + println!("The measurement is: {value}{unit_label}"); +} diff --git a/variables/Cargo.lock b/variables/Cargo.lock new file mode 100644 index 0000000..a6daf1d --- /dev/null +++ b/variables/Cargo.lock @@ -0,0 +1,7 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 3 + +[[package]] +name = "variables" +version = "0.1.0" diff --git a/variables/Cargo.toml b/variables/Cargo.toml new file mode 100644 index 0000000..f1cad76 --- /dev/null +++ b/variables/Cargo.toml @@ -0,0 +1,8 @@ +[package] +name = "variables" +version = "0.1.0" +edition = "2021" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] diff --git a/variables/src/main.rs b/variables/src/main.rs new file mode 100644 index 0000000..56ebdf0 --- /dev/null +++ b/variables/src/main.rs @@ -0,0 +1,11 @@ +fn main() { + let x = 5; + let x = x + 1; + + { + let x=x*2; + println!("The value of x in the inner scope is: {x}"); + } + + println!("The value of x is: {x}"); +}