Welcome to the Rust programming tutorial! Learn the fundamentals of Rust and get started with your first program.
fn main() { println!("Hello, world!"); }
This is the first Rust program. It prints "Hello, world!" to the console.
let age = 25; // integer
let pi = 3.14159; // floating-point
Rust uses type inference to determine the type of variables. You can declare variables explicitly or let the compiler infer their types.
Data structures are essential for organizing and manipulating data in Rust programs.
if condition { ... } else { ... }
while loop { ... }
for loop { ... }
Control flow statements allow you to execute blocks of code based on certain conditions.
fn greet(name: &str) { println!("Hello, {}", name); }
Functions are used to organize code and reuse it in different parts of a program.
use std::io::{Result, Read};
Error handling is crucial for building robust and reliable applications in Rust.
let s1 = String::from("hello");
Rust's ownership system ensures safe and efficient memory management by tracking where each piece of data lives and who owns it.
impl Trait for Type { fn method() {} }
Traits enable code reuse and abstraction by defining common behaviors for related types.
struct MyData<'a> { value: &'a str }
Lifetimes are used to ensure that references are valid for the duration they're used.
Rust is a powerful and safe language suitable for systems programming and web development. By learning the basics, you can build complex applications with confidence.