Skip to content

Instantly share code, notes, and snippets.

@kstep
Last active August 29, 2015 14:23
Show Gist options
  • Save kstep/9051def83211d0a386c0 to your computer and use it in GitHub Desktop.
Save kstep/9051def83211d0a386c0 to your computer and use it in GitHub Desktop.
run rust as script
#!/bin/sh
SELF="$1"
MD5=$(md5sum "${SELF}" | cut -f1 -d" ")
OUT="${SELF}.${MD5}.out"
if [ ! -f "${OUT}" ]; then
rustc -C debuginfo=0 -C prefer-dynamic "${SELF}" -o "${OUT}" || exit 1
fi
shift
exec "${OUT}" "$@"
@kstep
Copy link
Author

kstep commented Jun 29, 2015

E.g.:

#!/usr/local/bin/rustrun

fn main() {
  println!("Hello, world!");
}

Then chmod a+x hello.rs and run ./hello.rs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment