Rust
Designed to write fast, correct code for large scale maintable systems and embeddable into other languages
Safety and control
Safe by design, can't have seg fault, null ptrs, and dangling ptrs, or parallel dat race
Enums with match, structs, tuples, options, traits that can be implemented or put in generics
Default immutable and no shared memory, its all opt in with mut and unsafe blocks for everything not allowed
Rust can talk to C, basically directly with ft calls
fn main() {
println!("Hello World!");
}rustc hello.rs
./helloBasics Variables and Types?
rust infers types
//Can specify types, but optional
let x: i32 = 42; //i32 good for everything, long in C, int in Java, and dfault
let b: f64 = 3.14; // 64-bit float
let c: bool = true;
let d: char = 'z';
let e: &str = "Hello"; // String slice
let mut s = String::from("hello"); //String object that is mutable
s.push_str(", world!");
let pair: (char, i32) = ('a', 17)
pair.0; //a
pair.1 //17
let (_, r) = slice.split_at(middle)Lists
Control
Functions
Struct and Enum
Error Handling
Traits and Generic Types
Ownership and Borrowing
Concurrency
Threads can communiate by channel
Modules and Crates
Last updated