| Crates.io | twoslash-rust |
| lib.rs | twoslash-rust |
| version | 0.0.3 |
| created_at | 2026-01-16 12:00:09.940661+00 |
| updated_at | 2026-01-16 18:06:13.483484+00 |
| description | Twoslash for Rust - extract type information from Rust code using rust-analyzer |
| homepage | |
| repository | https://github.com/wevm/vocs |
| max_upload_size | |
| id | 2048488 |
| size | 158,747 |
Twoslash backend for Rust code, powered by rust-analyzer. Extracts type information, hover docs, and completions from Rust code.
cargo install twoslash-rust
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
--cargo-toml <path> — Use a custom Cargo.toml for dependencies--target-dir <path> — Specify a custom target directory for cachingSet 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>
Build the binary:
cargo build --release
Use --release for development. rust-analyzer is slow at indexing sysroot in debug builds.