rust-meth 0.3.0

Discover methods available on any Rust type with fuzzy filtering, inline documentation, interactive selection, and go-to-definition.
rust-meth-0.3.0 is not a library.
Visit the last successful build: rust-meth-0.2.1

rust-meth

rust-meth is a type-first method discovery tool for Rust.

Crates.io Nix Flake Documentation License

Discover the methods available on any Rust type. With fuzzy filtering, inline docs, interactive selection, and go-to-definition into the standard library source. Powered by rust-analyzer.

Think of it as "method completion for any Rust type, anywhere in your terminal."

[!IMPORTANT]

  • Standard Toolchain: Fully supported (std, core, and alloc).
  • External Crates: Supported via the --deps flag (see 3rd party crates).

Workspace Structure

rust-meth is a Cargo workspace. The CLI (rust-meth) is the user-facing binary; the core analysis logic lives in the rust-meth-lib library crate.

Crate Path Description
rust-meth cli/ CLI binary — argument parsing, output, interactive UI
rust-meth-lib lib/ Library — rust-analyzer integration, type resolution, method lookup

Highlights

  • Inspect any type's methods and full signatures
  • Fuzzy-filter results with partial or typo-ridden input
  • Show doc comments inline with --doc
  • Browse methods interactively with -i
  • Jump to the stdlib source of any method with --gd
  • Open that definition directly in your $EDITOR with --open
  • Open official documentation in your browser with --open-doc
  • Query 3rd party crate types with --deps
  • Colorized output, JSON output, and call snippets

Requirements

  • A Rust toolchain (stable or nightly)
  • rust-analyzer on your PATH:
    rustup component add rust-analyzer
    
  • rust-src (for go-to-definition):
    rustup component add rust-src
    

Installation

cargo install rust-meth

Usage

rust-meth <type> [filter] [flags]
rust-meth u8 wrapping
rust-meth '&str' splt          # fuzzy — finds split_*
rust-meth 'Vec<u8>' -i         # interactive picker
rust-meth u8 strict_shr --doc  # inline documentation
rust-meth u8 --gd checked_add  # go-to-definition
rust-meth u8 --gd isqrt --open # open in $EDITOR
rust-meth u8 --gd isqrt --open-doc  # open in browser
rust-meth 'serde_json::Value'  # 3rd party crate
rust-meth u8 wrapping --snippet
rust-meth u8 wrapping --json

For full flag reference and detailed examples, see the sections below.

Table of Contents

Fuzzy filter

The filter argument uses fuzzy matching — typos and partials work:

rust-meth u8 wrapng        # finds all wrapping_* methods
rust-meth '&str' splt      # finds split_*

Results are sorted by match quality, best first.

Inline documentation

Pass --doc / -d to print the doc comment below each method:

rust-meth u8 strict_shr --doc
rust-meth '&str' split_once --doc
rust-meth 'HashMap<String, u32>' entry --doc

Also works in interactive mode.

Interactive picker

Pass -i / --interactive to get a live fuzzy selector:

rust-meth u8 -i
rust-meth 'HashMap<String, u32>' -i
rust-meth u8 -i --doc   # also shows doc for selected method

Type to narrow, arrow keys to move, Enter to select, Esc to quit.

Go to definition

Pass --gd <method> to find where a method is defined in the stdlib source:

rust-meth u8 --gd checked_add
# u8::checked_add  library/core/src/num/uint_macros.rs:902

rust-meth u8 --gd checked_add --open
# opens uint_macros.rs at line 902 in $EDITOR

Supports hx, nvim, vim, emacs, and code. Requires $EDITOR to be set.

Open in browser

Pass --open-doc with --gd to open the official docs in your browser:

rust-meth u8 --gd isqrt --open-doc
rust-meth 'Vec<u8>' --gd push --open-doc
rust-meth 'HashMap<String, u32>' --gd get --open-doc

[!NOTE] --open and --open-doc are mutually exclusive. --gd currently only works for standard library types.

3rd party crates

For types where the crate name matches the type path prefix, --deps can be omitted:

rust-meth 'serde_json::Value'
rust-meth 'tokio::net::TcpStream' --doc
rust-meth 'serde_json::Value' -i

Use --deps to pin a version or add features:

rust-meth 'serde_json::Value' --deps 'serde_json = "1.0"'
rust-meth 'reqwest::Client' --deps 'reqwest = "0.11"
tokio = { version = "1", features = ["full"] }'

[!NOTE] First-time queries may take 5–10 seconds as rust-analyzer downloads and indexes dependencies.

Call snippets

Pass --snippet to print each method as a ready-to-paste call site:

rust-meth u8 wrapping --snippet
#   const fn(self, u8) -> u8
#   → x.wrapping_add(u8)
#
#   const fn(self) -> u8
#   → x.wrapping_neg()

JSON output

Pass --json for machine-friendly output (pipe into jq, scripts, etc.):

rust-meth u8 wrapping --json

Each item includes name, detail (full signature), and documentation.

How it works

See ARCHITECTURE.md and the lib crate README.

License

Apache-2.0