From 789ff7c04de4050aa62c3ac7b304b4e1b5ffcdde Mon Sep 17 00:00:00 2001 From: AlphonseMehounme Date: Tue, 26 Nov 2024 20:36:07 +0100 Subject: [PATCH] improve function with other functions and comments --- Rust/functions.rs | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/Rust/functions.rs b/Rust/functions.rs index ce5c607..d4188db 100644 --- a/Rust/functions.rs +++ b/Rust/functions.rs @@ -1,3 +1,4 @@ +// Main function fn main() { println!("Hello, Satoshi!"); @@ -5,13 +6,28 @@ fn main() { another_function(99999); - print_labeled_measurement(21000, 's') + print_labeled_measurement(21000, 's'); + + let x = { + let y = 6; + y + 1 + }; + println!("Value of x is: {x}."); + let x = five(); + println!("Value of x is now: {x}.") } +// Simple function that print provided Bitcoin Price fn another_function(x: i32) { println!("The Bitcoin price is {x}"); } +// Function that prints value and unit fn print_labeled_measurement(value: i32, unit_label: char) { println!("Bitcoin Balance : {value}{unit_label}"); } + +// Function that returns 5 +fn five() -> i32 { + 5 +}