function, statement, expression

This commit is contained in:
Tahinli 2023-04-27 13:06:44 +03:00
parent 613181e15b
commit 16e5de26bc
2 changed files with 34 additions and 0 deletions

8
5-functions/Cargo.toml Normal file
View file

@ -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]

26
5-functions/src/main.rs Normal file
View file

@ -0,0 +1,26 @@
fn main()
{
hello();
let x = {
let y = 5; //Statement
y+0 //Expression
};
println!("X = {}", x);
let y = return_value(x);
println!("Y = {}", y)
}
fn hello()
{
println!("Hello World");
}
fn return_value(mut x:i32) -> i32
{
println!("We're going to return something");
x = x+1;
x*x
}