Skip to content

Basic of Rust , Types, Enums, Patterns, Structs, Borrow Checking

Notifications You must be signed in to change notification settings

psidh/RustRover

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

RustRover

Welcome to our Rusty Codebase! 🦀 This repository is a treasure trove of Rust goodness, showcasing the power and elegance of the language. Strap in and get ready to explore variables, memory management, borrow checking, enums, pattern matching, crates, errors, and structs like never before.

Variables Galore

// Declare some variables
let x = 42;
let mut y = "Hello, world!";
let z: f64 = 3.14;

// Print them out
println!("x: {}", x);
println!("y: {}", y);
println!("z: {}", z);

Memory Management Magic

// Allocate memory dynamically
let mut v = Vec::new();

// Push some values onto the vector
v.push(1);
v.push(2);
v.push(3);

// Pop a value off the vector
let popped = v.pop();

println!("Popped value: {:?}", popped);

Borrow Checking Bonanza

// Create a string
let mut s = String::from("hello");

// Pass a reference to the string
let len = calculate_length(&s);

// Define a function that borrows a string
fn calculate_length(s: &String) -> usize {
    s.len()
}

println!("Length of '{}' is {}.", s, len);

...any many more!,

Dive into this codebase and unlock the secrets of Rust programming! Happy coding! 🚀