Rustのshebang comment

shebangはRustではコメントとみなされる。

#!/bin/cat

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

shebangとみなされる条件は、

  • ファイル(字句解析の処理単位)の先頭である。
  • #! で始まっている。
  • #![ で始まっていない。

である。LF \n またはファイルの末尾までがshebangとみなされる。

当然ながら、UTF-8で解釈できないバイト列を置くことはできない。