Skip to content

Rewrite your app in Rust, piece by piece, checked against the original at every step. Works with TypeScript, JavaScript, Python, Go, Ruby, Java, C, PHP, C#, Kotlin, PowerShell and Swift.

1.5 KB
Raw Blame

title: Shadow description: shadow generates a drop-in module that runs the original and the Rust side by side and reports mismatches.

Shadow

rust-anything shadow <crate>

shadow generates a drop-in with the original's API: a TS or Python module, a Go package, a Ruby file, Java classes (for Java and Kotlin) or a C file. Load it where the app loaded the original. It runs both, returns the original's result, and reports Rust mismatches while you build confidence in production.

Four languages have no shadow module yet, and shadow stops with what to do instead once diff passes:

Language Instead
PHP PHP cannot redefine a function once the original is loaded: require the generated PHP wrapper in place of the original files
C# C# binds calls when it compiles: compile the generated wrapper into the project and call the <namespace>.Rust classes (or alias them with using), with the built library next to the app
PowerShell rust-anything enable <crate> dot-sources the generated wrapper at the end of the original file
Swift Swift binds calls when it compiles: compile the generated wrapper into the target in place of the original file
RUST_ANYTHING_MODE Behavior
shadow (default) runs both, returns the original's result, reports mismatches
new switches to Rust
old turns Rust off

The public API does not change. Callers import the same functions, or the shadow module in their place.