Rust Playground At Your FingertipsSergey Potapov March 12, 2021 #rust
Coming to Rust from Ruby I miss the interactive console (IRB) lot.
Sometimes I go to Rust Plyaground online to test simple things,
but more often I go to
/tmp directory, create a new rust project, open Vim, run
cargo watch -x run and play.
It's very frequent scenario, why not automate it? This way I came to
a little shell script that relies on
#!/bin/sh PLAYGROUNDS_DIR="/tmp/rust-playgrounds" TIMESTAMP= PROJECT_DIR="/playground" # Add dependencies to Cargo.toml for; do done ;
I saved as
playground executable and put it into a directory with other binaries.
Now let's say I want to play with whatlang crate, then I just type:
What I get is a project with
whatlang dependency in
Cargo.toml opened and running automatically.
I just need to type, save, and the result is shown immediately.