AI prompts
base on Visualize Ownership and Lifetimes in Rust <div align="center">
<h1>
<picture>
<source media="(prefers-color-scheme: dark)" srcset="docs/assets/rustowl-logo-dark.svg">
<img alt="RustOwl" src="docs/assets/rustowl-logo.svg" width="400">
</picture>
</h1>
<p>
Visualize ownership and lifetimes in Rust for debugging and optimization
</p>
<h4>
<a href="https://crates.io/crates/rustowl">
<img alt="Crates.io Version" src="https://img.shields.io/crates/v/rustowl?style=for-the-badge">
</a>
<a href="https://aur.archlinux.org/packages/rustowl-bin">
<img alt="AUR Version" src="https://img.shields.io/aur/version/rustowl-bin?style=for-the-badge">
</a>
<img alt="WinGet Package Version" src="https://img.shields.io/winget/v/Cordx56.Rustowl?style=for-the-badge">
</h4>
<h4>
<a href="https://marketplace.visualstudio.com/items?itemName=cordx56.rustowl-vscode">
<img alt="Visual Studio Marketplace Version" 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 alt="Open VSX Version" 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 alt="JetBrains Plugin Version" src="https://img.shields.io/jetbrains/plugin/v/26504-rustowl?style=for-the-badge">
</a>
</h4>
<h4>
<a href="https://discord.gg/XbxN949dpG">
<img alt="Discord" src="https://img.shields.io/discord/1379759912942436372?style=for-the-badge&logo=discord">
</a>
</h4>
<p>
<img src="docs/assets/readme-screenshot-3.png" />
</p>
</div>
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
Detailed usage is described [here](docs/usage.md).
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.
## Table Of Contents
<!--toc:start-->
- [Support](#support)
- [Quick Start](#quick-start)
- [Prerequisite](#prerequisite)
- [VS Code](#vs-code)
- [Vscodium](#vscodium)
- [Other editor support](#other-editor-support)
- [Neovim](#neovim)
- [Emacs](#emacs)
- [RustRover / IntelliJ IDEs](#rustrover--intellij-ides)
- [Sublime Text](#sublime-text)
- [Architecture / OS / package repositories](#architecture--os--package-repositories)
- [Cargo Binstall](#cargo-binstall)
- [Windows](#windows)
- [Archlinux](#archlinux)
- [Nix flake](#nix-flake)
- [GitHub Release](#github-release)
- [Docker](#docker)
- [Build manually](#build-manually)
- [Note](#note)
<!--toc:end-->
## Support
If you're looking for support, please consider checking all issues, existing discussions, and [starting a discussion](https://github.com/cordx56/rustowl/discussions/new?category=q-a) 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](https://rustup.rs/).
- 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](https://marketplace.visualstudio.com/items?itemName=cordx56.rustowl-vscode).
RustOwl will be installed automatically when the extension is activated.
### Vscodium
You can install Vscodium extension from [this link](https://open-vsx.org/extension/cordx56/rustowl-vscode).
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](docs/installation.md) 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](docs/lsp-spec.md).
### Neovim
Minimal setup with [lazy.nvim](https://github.com/folke/lazy.nvim):
```lua
{
'cordx56/rustowl',
version = '*', -- Latest stable version
build = 'cargo binstall rustowl',
lazy = false, -- This plugin is already lazy
opts = {},
}
```
For comprehensive configuration options including custom highlight colors, see the [Neovim Configuration Guide](docs/neovim-configuration.md).
<details>
<summary>Recommended configuration: <b>Click to expand</b></summary>
```lua
{
'cordx56/rustowl',
version = '*', -- Latest stable version
build = 'cargo binstall rustowl',
lazy = false, -- This plugin is already lazy
opts = {
client = {
on_attach = function(_, buffer)
vim.keymap.set('n', '<leader>o', function()
require('rustowl').toggle(buffer)
end, { buffer = buffer, desc = 'Toggle RustOwl' })
end
},
},
}
```
</details>
Default options:
```lua
{
auto_attach = true, -- Auto attach the RustOwl LSP client when opening a Rust file
auto_enable = false, -- Enable RustOwl immediately when attaching the LSP client
idle_time = 500, -- Time in milliseconds to hover with the cursor before triggering RustOwl
client = {}, -- LSP client configuration that gets passed to `vim.lsp.start`
highlight_style = 'undercurl', -- You can also use 'underline'
colors = { -- Customize highlight colors (hex colors)
lifetime = '#00cc00', -- 🟩 green: variable's actual lifetime
imm_borrow = '#0000cc', -- 🟦 blue: immutable borrowing
mut_borrow = '#cc00cc', -- 🟪 purple: mutable borrowing
move = '#cccc00', -- 🟧 orange: value moved
call = '#cccc00', -- 🟧 orange: function call
outlive = '#cc0000', -- 🟥 red: lifetime error
},
}
```
When opening a Rust file, the Neovim plugin creates the `Rustowl` user command:
```vim
:Rustowl {subcommand}
```
where `{subcommand}` can be one of:
- `start_client`: Start the rustowl LSP client.
- `stop_client`: Stop the rustowl LSP client.
- `restart_client`: Restart the rustowl LSP client.
- `enable`: Enable rustowl highlights.
- `disable`: Disable rustowl highlights.
- `toggle`: Toggle rustowl highlights.
### Emacs
Elpaca example:
```elisp
(elpaca
(rustowl
:host github
:repo "cordx56/rustowl"))
```
Then use-package:
```elisp
(use-package rustowl
:after lsp-mode)
```
You have to install RustOwl LSP server manually.
### RustRover / IntelliJ IDEs
There is a [third-party repository](https://github.com/siketyan/intellij-rustowl) that supports IntelliJ IDEs.
You have to install RustOwl LSP server manually.
### Sublime Text
There is a [third-party repository](https://github.com/CREAsTIVE/LSP-rustowl) that supports Sublime Text.
## Architecture / OS / package repositories
### [Cargo Binstall](https://github.com/cargo-bins/cargo-binstall)
One of the easiest way to install RustOwl is using cargo-binstall.
```bash
cargo binstall rustowl
```
Toolchain is automatically Downloaded and unpacked.
### Windows
We have a winget package, install with:
```sh
winget install rustowl
```
### Archlinux
We have an AUR package. It downloads prebuilt binaries from release page. Run:
```sh
yay -S rustowl-bin
```
If you would like to build from that version instead:
```sh
yay -S rustowl
```
Replace `yay` with your AUR helper of choice.
We also have a git version, that builds from source:
```sh
yay -S rustowl-git
```
### Nix flake
There is a [third-party Nix flake repository](https://github.com/nix-community/rustowl-flake) in the Nix community.
### GitHub Release
Download only `rustowl` executable from [release page](https://github.com/cordx56/rustowl/releases/latest) 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).
1. Pull the latest stable image
```sh
docker pull ghcr.io/cordx56/rustowl:latest
```
Or pull a specific version:
```sh
docker pull ghcr.io/cordx56/rustowl:v0.3.4
```
2. Run the image
```sh
docker run --rm -v /path/to/project:/app ghcr.io/cordx56/rustowl:latest
```
You can also pass command-line arguments as needed:
```sh
docker run --rm /path/to/project:/app ghcr.io/cordx56/rustowl:latest --help
```
3. (Optional) Use as a CLI
To use `rustowl` as if it were installed on your system, you can create a shell alias:
```sh
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](docs/build.md) 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.
", Assign "at most 3 tags" to the expected json: {"id":"12964","tags":[]} "only from the tags list I provide: [{"id":77,"name":"3d"},{"id":89,"name":"agent"},{"id":17,"name":"ai"},{"id":54,"name":"algorithm"},{"id":24,"name":"api"},{"id":44,"name":"authentication"},{"id":3,"name":"aws"},{"id":27,"name":"backend"},{"id":60,"name":"benchmark"},{"id":72,"name":"best-practices"},{"id":39,"name":"bitcoin"},{"id":37,"name":"blockchain"},{"id":1,"name":"blog"},{"id":45,"name":"bundler"},{"id":58,"name":"cache"},{"id":21,"name":"chat"},{"id":49,"name":"cicd"},{"id":4,"name":"cli"},{"id":64,"name":"cloud-native"},{"id":48,"name":"cms"},{"id":61,"name":"compiler"},{"id":68,"name":"containerization"},{"id":92,"name":"crm"},{"id":34,"name":"data"},{"id":47,"name":"database"},{"id":8,"name":"declarative-gui "},{"id":9,"name":"deploy-tool"},{"id":53,"name":"desktop-app"},{"id":6,"name":"dev-exp-lib"},{"id":59,"name":"dev-tool"},{"id":13,"name":"ecommerce"},{"id":26,"name":"editor"},{"id":66,"name":"emulator"},{"id":62,"name":"filesystem"},{"id":80,"name":"finance"},{"id":15,"name":"firmware"},{"id":73,"name":"for-fun"},{"id":2,"name":"framework"},{"id":11,"name":"frontend"},{"id":22,"name":"game"},{"id":81,"name":"game-engine "},{"id":23,"name":"graphql"},{"id":84,"name":"gui"},{"id":91,"name":"http"},{"id":5,"name":"http-client"},{"id":51,"name":"iac"},{"id":30,"name":"ide"},{"id":78,"name":"iot"},{"id":40,"name":"json"},{"id":83,"name":"julian"},{"id":38,"name":"k8s"},{"id":31,"name":"language"},{"id":10,"name":"learning-resource"},{"id":33,"name":"lib"},{"id":41,"name":"linter"},{"id":28,"name":"lms"},{"id":16,"name":"logging"},{"id":76,"name":"low-code"},{"id":90,"name":"message-queue"},{"id":42,"name":"mobile-app"},{"id":18,"name":"monitoring"},{"id":36,"name":"networking"},{"id":7,"name":"node-version"},{"id":55,"name":"nosql"},{"id":57,"name":"observability"},{"id":46,"name":"orm"},{"id":52,"name":"os"},{"id":14,"name":"parser"},{"id":74,"name":"react"},{"id":82,"name":"real-time"},{"id":56,"name":"robot"},{"id":65,"name":"runtime"},{"id":32,"name":"sdk"},{"id":71,"name":"search"},{"id":63,"name":"secrets"},{"id":25,"name":"security"},{"id":85,"name":"server"},{"id":86,"name":"serverless"},{"id":70,"name":"storage"},{"id":75,"name":"system-design"},{"id":79,"name":"terminal"},{"id":29,"name":"testing"},{"id":12,"name":"ui"},{"id":50,"name":"ux"},{"id":88,"name":"video"},{"id":20,"name":"web-app"},{"id":35,"name":"web-server"},{"id":43,"name":"webassembly"},{"id":69,"name":"workflow"},{"id":87,"name":"yaml"}]" returns me the "expected json"