Thanks to visit codestin.com
Credit goes to github.com

Skip to content

wvhulle/ferrous-owl

 
 

Repository files navigation

FerrousOwl

This binary aims to help new users of Rust struggling with the ownership system.

The editor extensions that use this binary visualize ownership movement and lifetimes with colored underlines. The color mapping is roughly as follows:

  • 🟩 Green: variable's actual lifetime
  • 🟦 Blue: immutable borrow
  • 🟪 Purple: mutable borrow
  • 🟧 Orange: value moved / function call
  • 🟥 Red: lifetime error (invalid overlap or mismatch)

Exact colors may vary upon editor or chosen color theme. In Helix, for example, less colors are available.

Usage

Run this binary (done automatically when editor if an editor extension is configured):

ferrous-owl

Don't pass any arguments to the binary like --stdio, it listens to stdin by default.

  1. Open a Rust file in your editor (must be part of a Cargo workspace).
  2. Place the cursor on a variable definition or reference.
  3. Analysis should start automatically (check the extension status) and complete in a few seconds.
  4. Select a variable definition or reference for which you want to see ownership changes.
  5. Hover over the underlined lines to check ownership status changes

In some editors, you might need to manually enable ownership diagnostics with a code action.

Installation

Install system packages:

  • Rust compiler toolchain: rustup (install)
  • C compiler (gcc, clang, or Visual Studio on Windows)

Install required Rust compiler components:

rustup update nightly
rustup toolchain install nightly --component rustc-dev rust-src llvm-tools

Then install ferrous-owl:

cargo +nightly install ferrous-owl --locked

Make sure the ~/.cargo/bin directory is in your path. Then, configure one of the editor extensions that are supported out of the box (see editors/):

FerrousOwl uses an extended LSP protocol, so it can be integrated with other editors.

Notes

println! macro may produce extra output (does not affect usability).

About

Show Rust data ownership flow as diagnostics in your editor

Topics

Resources

License

Contributing

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Rust 83.0%
  • TypeScript 14.0%
  • JavaScript 2.1%
  • Nix 0.9%