This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| fn main() { | |
| function_with_parameters(7); | |
| } | |
| fn function_with_parameters(x: i32) { | |
| println!("The value of x is: {x} "); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| fn main() { | |
| hello(); | |
| } | |
| fn hello() { | |
| println!("Hello from my external function!"); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| fn main() { | |
| // Declare an array known as 5 with five entries, each of which is a signed 32 integer | |
| let a: [i32; 5] = [1, 2, 3, 4, 5]; | |
| // accessing the values of arrays | |
| let first = a[0]; | |
| let second = a[1]; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| fn main () { | |
| // This is a comment, with two forward slashes, we can leave comments | |
| // in our code to explain to readers what is happening! | |
| // declaring our tuple with a signed 32 bit integer, floating point 64 bit | |
| // and an unsigned 8 bit integer | |
| let tup: (i32, f64, u8) = (500, 6.4, 1); | |
| // to read tuple data, we need to match its format |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| fn main() { | |
| let a: char = 'a'; | |
| let cat_in_love = '😻'; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| fn main() { | |
| let t: bool = true; | |
| let f: bool = false; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| fn main() { | |
| let x: f64 = 2.0; | |
| let y: f32 = 1.0; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| fn main() { | |
| let a: u8; | |
| let b: u16; | |
| let c: u32; | |
| let d: u64; | |
| let e: u128; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| fn main() { | |
| let x = 5: | |
| let x = x + 1; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const THREE_HOURS_IN_SECONDS: u32 = 60 * 60 * 3; |