Examples how to use rust-script
Find a file
2026-01-31 18:41:34 +01:00
.gitignore initial 2026-01-31 18:41:34 +01:00
demo.rs initial 2026-01-31 18:41:34 +01:00
README.md initial 2026-01-31 18:41:34 +01:00
task_demo.rs initial 2026-01-31 18:41:34 +01:00

rust-script demo

Prereq:

Run script directly:

rust-script demo.rs

Create a binary and run it (example):

mkdir -p tmp
rust-script --pkg-path tmp -p demo.rs
# NOTE: the binary will have some generated name like demo_a52c79374dc3047b361b5783 
# It is recommended to rename it to demo e.g. by
# sed -i 's/name = "demo_[^"]*/name = "demo/' tmp/Cargo.toml
# or you can edit tmp/Cargo.toml manually 
cargo build -r --manifest-path tmp/Cargo.tomls
./tmp/target/release/demo  # demo only works if this is the name in Cargo.toml