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.
README
<img src="docs/assets/rustowl-logo.svg" width="400" />
</picture>
</h1>
<p>
Visualize ownership and lifetimes in Rust for debugging and optimization
</p>
<p>
You can try out RustOwl on <a href="https://play.rustowl.rs/">play.rustowl.rs</a>
</p>
<p>
<a href="https://crates.io/crates/rustowl">
<img src="https://img.shields.io/crates/v/rustowl?style=for-the-badge" />
</a>
<a href="https://aur.archlinux.org/packages/rustowl-bin">
<img src="https://img.shields.io/aur/version/rustowl-bin?style=for-the-badge" />
</a>
<img src="https://img.shields.io/winget/v/Cordx56.Rustowl?style=for-the-badge" />
</p>
<p>
<a href="https://marketplace.visualstudio.com/items?itemName=cordx56.rustowl-vscode">
<img src="https://img.shields.io/visual-studio-marketplace/v/cordx56.rustowl-vscode?style=for-the-badge&label=VS%20Code" />
</a>
<a href="https://open-vsx.org/extension/cordx56/rustowl-vscode">
<img src="https://img.shields.io/open-vsx/v/cordx56/rustowl-vscode?style=for-the-badge" />
</a>
<a href="https://github.com/siketyan/intellij-rustowl">
<img src="https://img.shields.io/jetbrains/plugin/v/26504-rustowl?style=for-the-badge" />
</a>
</p>
<p>
<a href="https://discord.gg/XbxN949dpG">
<img src="https://img.shields.io/discord/1379759912942436372?style=for-the-badge&logo=discord" />
</a>
</p>
<p>
<img src="docs/assets/readme-screenshot-3.png" />
</p>
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.
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.
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.