Rust is a compiled, statically typed language for performance- and safety-critical software. It is primarily suited to systems work, but can also target WebAssembly for web applications. Its safety guarantees come with a steeper learning curve and greater compilation-time complexity; choose it when those trade-offs fit the job. section 1.1 section 1.3
The features with the greatest implementation impact are:
- The borrow checker validates references at compile time. It permits multiple immutable references or one mutable reference, but not both at once; scope determines when resources can be released. section 1.2.1
- Traits, generics, closures, iterators, macros, and async/await support composition without relying on class inheritance. Cargo handles packages and builds. section 1.2.2 section 1.1
- Zero-cost abstractions and LLVM optimization make readable code a practical starting point for performance work. Measure and optimize further when the workload demands it. section 11.0
Handle a failing calculation explicitly
For an integer division that may fail, `checked_div` makes the outcome a value: `assert_eq!((100i32).checked_div(0i32), None);`. This is preferable to assuming the divisor is valid; division by zero otherwise panics in the illustrated Rust program. section 4.5.1
Use the compiler’s type and reference checks to narrow what tests must cover—not to replace tests. Test program logic, conversions, stateful operations, and I/O; avoid using `unwrap()` or `unsafe` merely to bypass edge cases. section 6.4
Table 11.1 Rust bindings and tooling for integrating Rust into other languages (view table figure)
| GitHub stars1 |
||||
|---|---|---|---|---|
| Rust bindings for Python, with tools for making native Python packages with Rust |
||||
| setuptools extension for including binaries in Python packages, including Rust |
||||
| Bindings between Ruby and Rust, which enable integrating Rust with Ruby or Ruby with Rust |
||||
| Library for creating safe bindings to Rust for Elixir and Erlang |
||||
The bindings table identifies options for adding safety-critical or compute-intensive Rust functions to existing Python, Ruby, Elixir, Erlang, and Node.js applications without a complete rewrite. section 11.5 section 11.0
Consider Rust for concurrent systems, embedded software, cryptography, legacy C or C++ replacement, and performance-critical components. If rapid development matters more than its safety and performance properties, another language may be a better fit. section 1.3.1 section 1.3





