Rust's borrow checker eliminates all memory related bugs.
The borrow checker enforces rules at compile time that other languages check at runtime (or not at all). Zero cost. Zero runtime overhead.
Memory safety without garbage collection.
Concurrency without data races.
Performance without compromise.
Guaranteed at compile time. No runtime overhead.
Rust's borrow checker eliminates all memory related bugs.
The borrow checker enforces rules at compile time that other languages check at runtime (or not at all). Zero cost. Zero runtime overhead.
fn main() -> Result<()> {
let s1 = String::from("hello");
let s2 = s1; // ownership moved
println!("", s2); // works
takes_ownership(s2);
// s2 is now invalid
}
fn takes_ownership(s: String) {
println!("", s);
} // s dropped, memory freed Traits. Monomorphization. Maximum performance.
trait Drawable {
fn draw(&self);
}
struct Circle { radius: f64 }
struct Square { side: f64 }
impl Drawable for Circle {
fn draw(&self) {
// Specialized implementation
}
}
fn render<T: Drawable>(item: &T) {
item.draw(); // Monomorphized
}
Write high-level, generic code. Get low-level performance.
Rust's trait system enables polymorphism without runtime overhead. Generic code is monomorphized: duplicated and specialized at compile time for each type used. The same performance as hand-written, type-specific code.
Production-ready libraries for every domain.
Asynchronous runtime. The foundation of async Rust.
Pure Rust audo decoding for almost every format.
Cook up gorgeous TUIs.
LLVM bindings. Build compilers with safety.
ECS game engine.
Type-safe graphics programming.
Cross platform windowing library.
Widely considered as the best HTTP request library.
C++ performance. Rust safety. No compromises.
Rust is fast. Really fast.
Zero-cost abstractions mean you pay nothing for safety. No garbage collection pauses. No runtime overhead. Predictable performance that matches or beats C++.
Rust — 1.0× baseline
C++ — 1.05× (comparable)
Go — 2.3× slower
Java — 3.1× slower
// Zero-cost iterator chains
let sum: u64 = (0..1_000_000)
.filter(|x| x % 2 == 0)
.map(|x| x * x)
.sum();
// Compiles to same assembly as
// a handwritten for-loop
// SIMD vectorization automatic
let dot_product = a.iter()
.zip(b.iter())
.map(|(x, y)| x * y)
.sum::<f64>();