All about rust

statically typed

Expression Based

Ownership: no need for garbage collector !

let first = v.get(0);
    
    println!("The first element is: {first:?}");
    // mutable reference
    let first_mut = v.get_mut(0);
    
    
    

mot this :

  let first = v.get(0);
    
   
    // mutable reference
    let first_mut = v.get_mut(0);
    
     println!("The first element is: {first:?}");

Rust doesn’t have the *null* feature that many other languages have

cargo check is much lighter:

Parse
Type check
Borrow check

while a full build:

Type check
Code generation
LLVM optimization
Linking

can hammer all cores for many minutes.

Commands

// formatting
rustfmt main.rs 
cargo fmt

// create a project using Cargo
cargo new <Name of the project / folder >

// cargo run : build -> compile -> run || uses sort of Caching & Checks the diff 
cargo run 

// cargo check : checks the linting error or the syntax error 
cargo check 

// cargo build : build -> compile : folder -> Debug [unoptimized]
cargo build 

<aside>

By default cargo builds debug version of our code which might be slow : For local Development

</aside>

// for production: [optimized build]
// make sure we are comfortable with "debug" then we step towards "release"
cargo build --release

// Run
cargo run --release