Rust is a compiled systems programming language, first released as stable in 2015 after starting at Mozilla. It guarantees memory safety and prevents data races at compile time through an ownership and borrowing system, without needing a garbage collector.
Why it matters
Rust offers performance comparable to C and C++ while ruling out whole classes of bugs such as use-after-free and buffer overflows in safe code. That makes it attractive for operating system components, browsers, command-line tools, WebAssembly and network services. The cost is a steeper learning curve: the borrow checker rejects programs that other languages would accept, and compile times can be long.
Example
fn main() {
let s = String::from("hello");
let t = s; // ownership moves to t
println!("{}", t); // ok
// println!("{}", s); // compile error: s was moved
}
Each value has a single owner. After the move, s can no longer be used, so the compiler stops a double free before the program ever runs.
Common mistakes
- Fighting the borrow checker by cloning everything instead of restructuring ownership.
- Overusing
unwrap(), which panics on an error or missing value. - Assuming
unsafeblocks are checked; inside them the programmer is responsible.
Related
Get notified when this term updates
Plus occasional practical tips on uptime and monitoring, nothing else. Unsubscribe anytime.
यह पेज सामान्य जानकारी है, जिसे हमारी संपादकीय टीम ने लिखा है और दस्तावेज़ीकरण बदलने पर अपडेट किया जाता है। सर्वर और प्रदाता अलग-अलग होते हैं, इसलिए बदलाव पहले सुरक्षित तरीके से जाँचें। देखें: संपादकीय नीति और अस्वीकरण.