Skip to content

Instantly share code, notes, and snippets.

@KeenS
Created January 26, 2018 10:23
Show Gist options
  • Select an option

  • Save KeenS/d0dd7beaf35f2c8889729957fc21a835 to your computer and use it in GitHub Desktop.

Select an option

Save KeenS/d0dd7beaf35f2c8889729957fc21a835 to your computer and use it in GitHub Desktop.
Rustでちろっとコード試すのに便利なシェル関数
#!/usr/bin/zsh
# cargo install cargo-scriptしておく。これだけでも便利
# 下記関数でタイプ数節約できる & ツールチェーン切り替えられる
rust() {
local toolchain=+stable
if [[ "$1" =~ "\+.+" ]]; then
toolchain="$1"
shift
fi
cargo "$toolchain" script "$@"
}
# $ rust hoge.rs
# $ rust +nightly hoge.rs
# $ rust -e '1 + 1'
# $ cat /etc/passwd | rust -l '|line| print!("{}", line)'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment