What is a .rs file?
Rust Source File · Code and data · Rust project (originally Mozilla) · 2010
A .rs file is Rust source code, a modern systems language focused on speed and memory safety without a garbage collector. It is plain text compiled by the Rust toolchain into fast native binaries.
What is a .rs file used for?
Rust's compiler enforces strict rules about how memory is used, catching whole classes of bugs before the program runs. Projects are usually built with Cargo, which handles dependencies and compilation with cargo build or cargo run.
Rust is used for performance-critical software, command-line tools, WebAssembly and increasingly parts of operating systems. The source files are plain text; VS Code with rust-analyzer is a common setup.
What opens a .rs file?
The .rs format opens in the following apps, grouped by operating system. If one app does not work, try another from the same list.
Windows
- VS Code
- RustRover
- any text editor
macOS
- VS Code
- RustRover
- any text editor
Linux
- VS Code
- vim
- any text editor
Open a .rs file step by step
- Confirm the file really is a .rs. Drop it into the WhatFileType identifier, which reads its signature in your browser without uploading anything.
- On Windows, open it with VS Code or RustRover.
- On Mac, use VS Code or RustRover.
- On Linux, try VS Code or vim.
- Still stuck? Convert the .rs to exe (via cargo build), which opens more widely.
Why can't I open my .rs file?
Almost always because no installed app understands Rust. Install one of the apps above, or convert the file to a format your existing software already reads. If double-clicking opens the wrong program instead of nothing at all, the file association is set to the wrong app rather than the file being broken.
The other possibility is that the file is not really a .rs at all. Drop it into the file identifier to check it by its bytes instead of its name. Nothing is uploaded.
How to convert a .rs file
You can convert a .rs file to exe (via cargo build), wasm using a conversion tool or the export menu of an app that opens it.
Rust has no fixed magic number, so there is no signature table on this page. Its bytes alone do not prove the format: identification relies on the extension, the structure of the content and the program that created it. The magic-numbers reference lists the formats that do carry one.
Frequently asked questions
What is a .rs file?
A .rs file is Rust source code, a modern systems language focused on speed and memory safety without a garbage collector. It is plain text compiled by the Rust toolchain into fast native binaries.
How do I run a .rs file?
In a Cargo project, cargo run builds and runs it. A single file can be compiled directly with rustc file.rs and then executed.
How do I open a .rs file?
Any text editor opens it. VS Code with the rust-analyzer extension adds completion, type hints and error checking.
Why is Rust considered safe?
Its compiler tracks ownership and borrowing of memory, preventing use-after-free and data races at compile time without a garbage collector.
Related formats
Sources
Details on this page were checked against authoritative references. How sources are ranked and what is deliberately left out is set out in the methodology.