RustOwl is a visualization tool designed to help Rust developers understand ownership and lifetimes in their code. It provides insights into how variables are borrowed, moved, or referenced, making it easier to debug and optimize Rust programs.
Key Features:
Visualizes variable ownership with color-coded underlines (e.g., green for actual lifetimes, blue for immutable borrowing).
Highlights mutable borrows, moves, and lifetime errors in real-time.
Supports multiple editors, including VSCode, Neovim, and Emacs, through an LSP server with extended capabilities.
Audience & Benefit:
Ideal for Rust developers to improve code quality by identifying ownership issues and lifetimes errors early. It helps reduce runtime bugs and enhances the overall efficiency of software development.
RustOwl visualizes ownership movement and lifetimes of variables.
When you save Rust source code, it is analyzed, and the ownership and lifetimes of variables are visualized when you hover over a variable or function call.
RustOwl visualizes those by using underlines:
🟩 green: variable's actual lifetime
🟦 blue: immutable borrowing
🟪 purple: mutable borrowing
🟧 orange: value moved / function call
🟥 red: lifetime error
diff of lifetime between actual and expected, or
invalid overlapped lifetime of mutable and shared (immutable) references
Currently, we offer VSCode extension, Neovim plugin and Emacs package.
For these editors, move the text cursor over the variable or function call you want to inspect and wait for 2 seconds to visualize the information.
We implemented LSP server with an extended protocol.
So, RustOwl can be used easily from other editor.
If you're looking for support, please consider checking all issues, existing discussions, and starting a discussion first!
Also, you can reach out to us on the Discord server provided above.
Quick Start
Here we describe how to start using RustOwl with VS Code.
Prerequisite
cargo installed
You can install cargo using rustup from this link.
Visual Studio Code (VS Code) installed
We tested this guide on macOS Sequoia 15.3.2 on arm64 architecture with VS Code 1.99.3 and cargo 1.89.0.
VS Code
You can install VS Code extension from this link.
RustOwl will be installed automatically when the extension is activated.
Vscodium
You can install Vscodium extension from this link.
RustOwl will be installed automatically when the extension is activated.
After installation, the extension will automatically run RustOwl when you save any Rust program in cargo workspace.
The initial analysis may take some time, but from the second run onward, compile caching is used to reduce the analysis time.
Other editor support
We support Neovim and Emacs.
You have to install RustOwl before using RustOwl with other editors.
You can also create your own LSP client.
If you would like to implement a client, please refer to the The RustOwl LSP specification.
Download only rustowl executable from release page and place it into the place you desire.
Toolchain is automatically Downloaded and unpacked.
Docker
You can run rustowl using the pre-built Docker image from GitHub Container Registry (GHCR).
Pull the latest stable image
docker pull ghcr.io/cordx56/rustowl:latest
Or pull a specific version:
docker pull ghcr.io/cordx56/rustowl:v0.3.4
Run the image
docker run --rm -v /path/to/project:/app ghcr.io/cordx56/rustowl:latest
You can also pass command-line arguments as needed:
docker run --rm /path/to/project:/app ghcr.io/cordx56/rustowl:latest --help
(Optional) Use as a CLI
To use rustowl as if it were installed on your system, you can create a shell alias:
alias rustowl='docker run --rm -v $(pwd):/app ghcr.io/cordx56/rustowl:latest'
Now you can run rustowl from your terminal like a regular command.
Build manually
There is a build guide to build RustOwl or extensions.
Note
In this tool, due to the limitations of VS Code's decoration specifications, characters with descenders, such as g or parentheses, may occasionally not display underlines properly.
Additionally, we observed that the println! macro sometimes produces extra output, though this does not affect usability in any significant way.