What is an RS file?
RS files contain source code in Rust, a systems programming language focused on three goals: safety, concurrency, and performance. Rust was initially created by Mozilla Research (Graydon Hoare), with version 1.0 released in 2015, and governance transferred to the independent Rust Foundation in 2021. Rust’s defining feature is its ownership system — a set of compile-time rules that guarantee memory safety without a garbage collector. This eliminates entire categories of bugs (null pointer dereferences, use-after-free, data races) that are common in C and C++.
Rust has been voted the “most admired” programming language in the Stack Overflow Developer Survey for nine consecutive years (2016–2024).
How to open RS files
- VS Code (Windows, macOS, Linux) — With the
rust-analyzerextension (official LSP) - RustRover (Windows, macOS, Linux) — JetBrains’ dedicated Rust IDE
- Vim/Neovim — With
rust-analyzervia nvim-lspconfig - Zed — Built with Rust, has native Rust support
- Any text editor — RS files are plain UTF-8 text
Technical specifications
| Property | Value |
|---|---|
| Typing | Static, strong, inferred |
| Paradigm | Multi-paradigm (functional, imperative, concurrent) |
| Compiler | rustc (LLVM-based backend) |
| Memory model | Ownership + borrow checker (no GC, no manual malloc) |
| Package manager | Cargo (crates.io registry) |
| Compilation | Ahead-of-time to native machine code |
| Current edition | Rust 2021 |
Common use cases
- Systems programming: Operating system components (Linux kernel has experimental Rust drivers), embedded systems
- WebAssembly: High-performance browser modules (wasm-pack compiles Rust to WASM)
- CLI tools:
ripgrep(rg),fd,bat,exa,delta— many popular Unix tools are written in Rust - Blockchain: Solana programs, Polkadot/Substrate runtimes, Near Protocol
- Game engines: Bevy, a modern ECS game engine written in Rust
- Web backends: Axum, Actix-web, Rocket frameworks for HTTP services
Rust code example
use std::collections::HashMap;
fn word_count(text: &str) -> HashMap<&str, usize> {
let mut counts = HashMap::new();
for word in text.split_whitespace() {
*counts.entry(word).or_insert(0) += 1;
}
counts
}
fn main() {
let text = "hello world hello rust world";
let counts = word_count(text);
for (word, count) in &counts {
println!("{word}: {count}");
}
}
Ownership and borrowing
Rust’s ownership rules: each value has exactly one owner; ownership can be moved or borrowed; when the owner goes out of scope, memory is freed. This eliminates the need for malloc/free or a garbage collector:
let s1 = String::from("hello");
let s2 = s1; // s1 is moved — using s1 now is a compile error
let s3 = s2.clone(); // explicit deep copy
let len = calculate(&s3); // borrow s3 (read-only reference)
// s3 still valid here
The borrow checker enforces these rules at compile time, making data races and memory corruption impossible in safe Rust code.
Cargo — the build system and package manager
cargo new my-project # Create new project
cargo build # Compile
cargo run # Compile and run
cargo test # Run tests
cargo add serde # Add dependency from crates.io
cargo clippy # Lint
cargo fmt # Format with rustfmt
Cargo manages dependencies in Cargo.toml, compiles the project, runs tests, generates documentation, and publishes packages to crates.io. It is widely considered one of the best package managers in any language ecosystem.
Unsafe Rust
Standard Rust enforces memory safety. The unsafe keyword creates a block where the programmer can bypass the borrow checker to: dereference raw pointers, call C functions via FFI, or implement unsafe traits. unsafe does not disable all checks — it only unlocks these specific operations, and the programmer takes responsibility for correctness within those blocks. Most Rust code never needs unsafe.