added function and variable lessons.

This commit is contained in:
gabe 2022-06-20 15:44:29 -05:00
parent 4106843d70
commit 405437686a
6 changed files with 118 additions and 0 deletions

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]

View file

@ -0,0 +1,16 @@
fn main() {
another_function(5);
print_labeled_measurement(50, 'm');
println!("The returned value is {}", plus_one(4));
}
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);
}
//adds one and returns
fn plus_one(x:i32) -> i32 {
x+1
}