Examples how to use rust-script
- Rust 100%
| .gitignore | ||
| demo.rs | ||
| README.md | ||
| task_demo.rs | ||
rust-script demo
Prereq:
- Rust installed - https://rust-lang.org/tools/install/
cargo install rust-script- see https://rust-script.org/
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