1. 15
  1. 5

    As cool as this is, kind of a misleading title:

    The first invocation of the script will be slower as the script is compiled

    1. 4

      There are a lot of “drivers” to “run” rust files in your shell that predate this (see cargo-script). But how about no dependencies instead?

      Earlier this year, I wrote about creating polyglot rust/sh files that can be compiled with rustc or executed directly (no deps or “interpreter”) just by copy and pasting a header to the top of your .rs files: https://neosmart.net/blog/2020/self-compiling-rust-code/

      1. 3
        $ rust-script hello # you can leave off the file extension
        Hello, World!

        Having just had to work around Info-ZIP’s automatic extension-appending in a script that used it, I can’t help but think this is a bad idea. Implicit automagic DWIMminess may occasionally have its place, but when it introduces gratuitous ambiguity to something as fundamental as what file a given name really refers to, I’ll pass, thanks.

        1. 1

          Reminds me of a “shebang for a C dynamic library” I saw recently in: https://github.com/kahing/bin/blob/master/cleancache.c