rust-anything checks a Rust rewrite against your old code
rust-anything is a command-line tool for coding agents moving existing code into Rust, using saved examples from the original to check each rewrite.
- Verdict
- Verdict: Adopt with care
- Tested
- Commit
b87820f- Source
- erkamyaman/rust-anything
- Author
- Kahtaf Alam

A coding agent can take on the work of translating a slow function into Rust. For code that spends its time parsing text or crunching numbers, compiled Rust can do that work in fewer CPU cycles. The harder question is whether the faster function still handles the odd input your application has accepted for years.
rust-anything gives the agent a way to check. Its command-line tool records what the original returns or throws, using generated inputs and examples you supply. You or the agent writes the Rust. The tool connects the new function to existing callers and replays the examples against it.
The project lists support for Node.js (TypeScript and JavaScript), Python, C, Go, Ruby and Java. You can start with one bottleneck. For a whole application, the project describes replacing one piece at a time. Our hands-on test followed two Python functions through that process.
rust-anything is MIT-licensed and maintained by developer erKam Yaman. It changes quickly: version 2.0 shipped three days after version 1.0.
Tested: commit
b87820fee6e067c3133961bd982d34ffa46a9bd6on November 19, 2026. Workflow: port two Python text functions, shell-style splitting and line wrapping, to Rust on Linux. Result: The text-splitting port passed every check. Comparing recorded calls revealed that the line-wrapping port rejected arguments the original accepted. Verdict: adopt with care. Start with a function whose behavior you can check against real calls.
Set up rust-anything with your coding agent
Paste this into your coding agent:
Install the latest rust-anything from https://github.com/erkamyaman/rust-anything.
Identify the language and port one slow function in a disposable copy with test data and no production credentials.
Preserve its public interface; review generated exports and test important errors independently.
Show correctness and performance results.
Python-to-Rust ports run faster on long text
rust-anything’s generated Python modules use PyO3, which connects Python calls to Rust functions. For Rust ports written by a coding agent from Python’s shlex (shell-like text splitting) and textwrap (line wrapping), each call on 11,000-character inputs, including the connection from Python to Rust, took:
| Long-text operation | Original Python, mean time | Rust port, mean time |
|---|---|---|
| Split shell-like text | 1.776 ms | 0.104 ms |
| Wrap text into lines | 1.287 ms | 0.041 ms |
Replaying recorded calls catches a binding that rejects valid arguments
The diff command replays recorded calls against the port. The gate command, the final check, reruns that replay and also checks formatting, compiler warnings, tests and the exported functions. If callers pass None to an on/off option, a Rust binding that requires a Boolean can reject a call Python accepts. Replaying one such call produced this error:
TypeError: 'None' is not an instance of 'bool'
Decide whether existing callers can pass those values: preserve their behavior in the binding, or document an intentional interface change in known-diffs.jsonl, the tool’s list of accepted differences. Changing the binding to treat None as false made every recorded call match and the final check pass.
Changing the original code makes diff reject the outdated recording. Record again after changing the original, then repair the port against the new results.
Users report gaps between recordings and real behavior
In a GitHub report about typed inputs, one developer found that rust-anything’s generated inputs looked nothing like their real objects, so argument errors buried the useful mismatches. Add representative inputs with record --inputs and inspect what the recording exercises.
In the r/ClaudeAI launch thread on Reddit, a developer describes regex matching and number formatting breaking their own rewrites outside recorded examples. Add regression examples for real bug reports, unusual characters and application-specific inputs.
Python exports and errors still need independent review
A module’s __all__ list names the functions it intends to expose. When a docstring (the documentation string at the top of a file) comes before __all__, rust-anything ignores the list and exports helpers outside it. Check rust-anything.json, the generated manifest, before porting; for a large module, isolate the intended functions behind a small adapter.
The Python replay check ignores error-message text and accepts a Rust binding’s TypeError (an argument-type error) when the original raised any error. Test important error types and messages independently.
Keep application tests alongside rust-anything
Adopt rust-anything with care for a gradual rewrite. Pick a bottleneck you can measure, save examples from real callers and time the complete call after the port. In Python, also check which functions the binding exposes and how it handles errors. For a one-off native function, direct PyO3 with maturin, a Rust-to-Python package builder, may be simpler. For Python speed alone, Cython compiles Python-oriented code into native extensions, while Numba compiles a supported subset of Python at runtime, especially numerical loops. Budget for maintaining the Rust build and Python wrapper. Keep application tests that check the behavior your callers depend on.