rustbook_learning_guide/
basics.rs

1//! Basic Rust concepts
2
3pub fn variable_examples() {
4    println!("\nšŸ“¦ Variable Examples");
5    println!("{}", "-".repeat(20));
6    
7    let x = 5;
8    let mut y = 10;
9    y += 5;
10    
11    println!("x = {}, y = {}", x, y);
12}
13
14pub fn control_flow_examples() {
15    println!("\nšŸ”„ Control Flow Examples");
16    println!("{}", "-".repeat(25));
17    
18    for i in 1..=3 {
19        if i % 2 == 0 {
20            println!("{} is even", i);
21        } else {
22            println!("{} is odd", i);
23        }
24    }
25}
26
27pub fn function_examples() {
28    println!("\nšŸ”§ Function Examples");
29    println!("{}", "-".repeat(20));
30    
31    fn add(a: i32, b: i32) -> i32 {
32        a + b
33    }
34    
35    println!("2 + 3 = {}", add(2, 3));
36}
37
38
39