hello world and variables exploration

This commit is contained in:
Sil Klaasboer
2025-12-18 11:25:05 +01:00
parent 72cf887104
commit 54afcf45ee
6 changed files with 53 additions and 0 deletions

7
hello_world/Cargo.lock generated Normal file
View File

@@ -0,0 +1,7 @@
# This file is automatically @generated by Cargo.
# It is not intended for manual editing.
version = 4
[[package]]
name = "hello_world"
version = "0.1.0"

6
hello_world/Cargo.toml Normal file
View File

@@ -0,0 +1,6 @@
[package]
name = "hello_world"
version = "0.1.0"
edition = "2024"
[dependencies]

3
hello_world/src/main.rs Normal file
View File

@@ -0,0 +1,3 @@
fn main() {
println!("Hello, world!");
}

7
variables/Cargo.lock generated Normal file
View File

@@ -0,0 +1,7 @@
# This file is automatically @generated by Cargo.
# It is not intended for manual editing.
version = 4
[[package]]
name = "variables"
version = "0.1.0"

6
variables/Cargo.toml Normal file
View File

@@ -0,0 +1,6 @@
[package]
name = "variables"
version = "0.1.0"
edition = "2024"
[dependencies]

24
variables/src/main.rs Normal file
View File

@@ -0,0 +1,24 @@
//global variables use const or static NOT let and need a type indication
const NAME : &str = "John";
const HEX_NUM : &i32 = &0x01;
fn main() {
// local variables dont need a type indication and are by default immutable
let local_name = "Dough";
let normal_int = 35;
let hex_int = 0x35;
let bin_int = 0b10101111;
//make them mutable by mut modifier
let mut middle_name = "Levy";
println!("temp middle name: {}",middle_name);
middle_name = "Cena";
println!("name: {} {} {}",NAME,middle_name, local_name);
println!("age: {}", normal_int);
println!("hex: {}",hex_int);
println!("const hex: {}",HEX_NUM);
println!("binary: {}",bin_int);
}