twoslash-rust

Crates.iotwoslash-rust
lib.rstwoslash-rust
version0.0.3
created_at2026-01-16 12:00:09.940661+00
updated_at2026-01-16 18:06:13.483484+00
descriptionTwoslash for Rust - extract type information from Rust code using rust-analyzer
homepage
repositoryhttps://github.com/wevm/vocs
max_upload_size
id2048488
size158,747
(tmm)

documentation

README

twoslash-rust

Twoslash backend for Rust code, powered by rust-analyzer. Extracts type information, hover docs, and completions from Rust code.

Installation

cargo install twoslash-rust

Usage

Pipe Rust code to the binary via stdin:

echo 'fn main() { let x = 42; }' | twoslash-rust

Output is JSON with type information:

{
  "hovers": [
    {
      "text": "i32",
      "line": 0,
      "character": 16,
      "length": 1
    }
  ],
  "queries": [],
  "completions": [],
  "highlights": [],
  "errors": []
}

Use twoslash query markers (// ^?) to extract types at specific positions:

echo 'fn main() {
  let x = 42;
//    ^?
}' | twoslash-rust

Options

  • --cargo-toml <path> — Use a custom Cargo.toml for dependencies
  • --target-dir <path> — Specify a custom target directory for caching

Server Mode

Set TWOSLASH_SERVER_UUID to run as a persistent TCP server for faster repeated queries:

TWOSLASH_SERVER_UUID=abc123 twoslash-rust
# Outputs: 127.0.0.1:<port>

Development

Build the binary:

cargo build --release

Use --release for development. rust-analyzer is slow at indexing sysroot in debug builds.

Commit count: 700

cargo fmt