diff --git a/hello_world/Cargo.lock b/hello_world/Cargo.lock new file mode 100644 index 0000000..ce5ee3d --- /dev/null +++ b/hello_world/Cargo.lock @@ -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" diff --git a/hello_world/Cargo.toml b/hello_world/Cargo.toml new file mode 100644 index 0000000..4f0a461 --- /dev/null +++ b/hello_world/Cargo.toml @@ -0,0 +1,6 @@ +[package] +name = "hello_world" +version = "0.1.0" +edition = "2024" + +[dependencies] diff --git a/hello_world/src/main.rs b/hello_world/src/main.rs new file mode 100644 index 0000000..e7a11a9 --- /dev/null +++ b/hello_world/src/main.rs @@ -0,0 +1,3 @@ +fn main() { + println!("Hello, world!"); +} diff --git a/variables/Cargo.lock b/variables/Cargo.lock new file mode 100644 index 0000000..f26e54f --- /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 = 4 + +[[package]] +name = "variables" +version = "0.1.0" diff --git a/variables/Cargo.toml b/variables/Cargo.toml new file mode 100644 index 0000000..c093eb6 --- /dev/null +++ b/variables/Cargo.toml @@ -0,0 +1,6 @@ +[package] +name = "variables" +version = "0.1.0" +edition = "2024" + +[dependencies] diff --git a/variables/src/main.rs b/variables/src/main.rs new file mode 100644 index 0000000..9ab9dfe --- /dev/null +++ b/variables/src/main.rs @@ -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); +}