rust-script 0.36.0

Command-line tool to run Rust "scripts" which can make use of crates.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
#!/bin/sh
set -e -u

# https://unix.stackexchange.com/questions/30091/fix-or-alternative-for-mktemp-in-os-x
mytmpdir=$(mktemp -d 2>/dev/null || mktemp -d -t 'mytmpdir')

cd "$mytmpdir"

printf 'let msg = option_env!("_RUST_SCRIPT_TEST_MESSAGE").unwrap_or("undefined"); println!("msg = {}", msg);' > script.rs

rust-script script.rs

export _RUST_SCRIPT_TEST_MESSAGE=hello

rust-script script.rs

rust-script --force script.rs