by dherman · 11mo ago · 0 comments
//$HOME/.cargo/bin/rustc "$0" && ${0%.rs} "$@" ; exit
use std::env;
fn main() {
println!("hello, world!");
for arg in env::args() {
println!("arg: {arg}");
}
}
Total hack, and it litters ./ with the generated executable. But cute.```
$ echo 'fn main() { println!("hello, world!") }' > file.rs; hyperfine --warmup 1 'cargo +nightly -Zscript file.rs'
Benchmark 1: cargo +nightly -Zscript file.rs
Time (mean ± σ): 14.0 ms ± 1.0 ms [User: 7.7 ms, System: 9.7 ms]
Range (min … max): 12.2 ms … 17.5 ms 203 runs
```