Incrementally rewrite an app in Rust, checked against the original's recorded behavior
- Language
- Rust
- License
- MIT
- Stars
- 6.4K
- Try it
cargo install rust-anything
rust-anything, a new open-source tool from developer erkamyaman, helps you move an existing program to Rust in small pieces. At each step it checks that the Rust version does exactly what the original did. GitHub's search API shows erkamyaman/rust-anything was created on November 16. By the evening of November 20 (UTC) it had about 6,400 stars and 505 forks under the MIT license. That's a steep climb: LavX News counted 2,421 stars on November 18 at 12:16 UTC.
Why it matters: "rewrite it in Rust" usually stalls because nobody can prove the new code behaves like the old code. rust-anything doesn't translate code itself. Instead it records the original's behavior and keeps checking it. Coding agents (or you) write the Rust, and the tool refuses to sign off on a port until replays, benchmarks and checks all agree. explainx calls it "a parity-first migration harness, not a transpiler."
How it works
Both LavX and explainx describe the same pipeline, and the release notes back it up:
| Step | What it does |
|---|---|
| profile | Finds hot functions and their callers in the running app |
| analyze | Breaks the code into units, maps dependencies and risks, suggests a porting order |
| bridge | Generates language bindings plus Rust stubs so one function can be swapped at a time |
| record | Runs the original on generated edge cases, your own inputs, or calls captured from your test suite |
| diff | Replays every recorded case against the Rust port and reports mismatches |
| bench | Times the original against the replacement |
| shadow | Runs both in production but still returns the original's result |
| gate | Runs format, lint and tests, audits unsafe, and flags unported units and untested error paths |
According to LavX, the generated cases deliberately probe the spots where ports usually break: non-ASCII text, signed division, overflow, float formatting, and map and sort order. Version 2.0.1 (November 19) added more Unicode traps, such as superscripts, circled numbers, Arabic-Indic digits and characters beyond U+FFFF. explainx reports that you switch between old, shadow and new code paths with RUST_ANYTHING_MODE. There is also a whole-app mode that records a program's documented examples and tracks how often the Rust build still falls back to the original.
Bridges cover TypeScript/JavaScript (napi-rs or wasm-bindgen), Python (PyO3), C, Go (cgo), Ruby (Magnus) and Java (JNI). PHP and C# are in preview with whole-app record/replay only. LavX notes that per-unit bridges for those two are still future work.
Agent integration
According to explainx, rust-anything setup registers the tool as an MCP server and installs a workflow skill for Claude Code, Codex, Cursor and Gemini CLI. It backs up any config it touches. The v2.0.0 release notes add OpenCode to that list. In practice, the intended loop is an agent writing port.rs while rust-anything grades the work.
The author's numbers, and a retraction
The v2.0.0 release notes (November 19) claim these results. All of them are the author's own measurements and have not been reproduced independently:
| Port | Recorded cases matched | Claimed result |
|---|---|---|
| Prettier 3.6.2 (behind a Rust front door) | 17,224 / 17,224 | 91.9% of cases formatted fully in Rust; 19x faster per file on an Apple M4 |
| Fuse.js | 3,414 / 3,414 | 32x faster on 50,000 strings (5.3x on one core) |
| json-server | 514 / 514 HTTP cases | 3.5 MB idle memory vs 74 MB |
| vercel/ms | 975 / 975 | — |
Look at the Fuse.js footnote: much of the 32x comes from using more cores, not from Rust alone. The very next release, v2.0.1, withdrew a Java "3x batch" claim because the batch had run on four cores against a serial loop. Retracting that publicly is a good sign. It's also a reason to run bench on your own hardware before believing any headline speedup.
Limits
- It only checks what it recorded. Both write-ups stress that inputs nobody tried can still hide differences. explainx adds that concurrency, race conditions and security need separate testing, and that the gate is not formal verification.
- Nondeterminism needs work. Timestamps, UUIDs and similar output need normalizers or wildcards before diffs mean anything.
- Agents can still write bad Rust. explainx warns that the gate won't catch every unsafe pattern an agent produces.
- It's moving very fast. The project went from v1.0.1 to v2.0.2 between November 16 and 19, so the docs and the commands described in coverage may already be out of date. Recorders now have a watchdog with a default 10-second per-case timeout (
RUST_ANYTHING_CASE_TIMEOUT), added in v1.5.1 after long generated cases could hang.
Try it
cargo install rust-anything # also published to npm with prebuilt binaries
rust-anything setup # optional: register MCP server/skill with your agent
Who should care: teams with a slow, well-tested CLI, library or HTTP service where a Rust core would pay off, especially those already using coding agents. Start with one hot function in shadow mode and check the diff and bench output yourself. Don't treat a green gate as proof of equivalence.