About Rust Programming Language

Overview

Rust is a systems programming language that focuses on safety, speed, and concurrency. It provides memory safety guarantees and prevents many common programming errors.

Example: Hello World

Here's a basic "Hello, World!" program in Rust:

fn main() {
    println!("Hello, World!");
}

Variables and Operations

Rust supports variables and operations similarly to other languages:

fn main() {
    let a = 10;
    let b = 5;
    let sum = a + b;
    let product = a * b;

    println!("Sum: {}", sum);
    println!("Product: {}", product);
}

Conditional Statements

Using conditional statements in Rust:

fn main() {
    let number = 10;

    if number > 0 {
        println!("The number is positive.");
    } else {
        println!("The number is not positive.");
    }
}

Loops

Example of a loop in Rust:

fn main() {
    for i in 1..=5 {
        println!("Number: {}", i);
    }
}