0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

Rustのコンパイルと実行をコマンドひとつで

Last updated at Posted at 2020-04-07

以下の記事の一部抜粋と + αとなっております。

Rustを0から学んでみた 〜Part.0 準備/概要 編〜 - Yuto Hongo Portfolio


Macでの利用で、Rustのコンパイラのインストールとpath設定ができている前提となっております。

1. シェルスクリプトの関数として準備

処理内容

  1. .rsファイルと同じ場所にコンパイル後の実行ファイルを保存
  2. コンパイル後のファイルを実行

スクリプト

.bashrcや.bash_profileなど
# !/bin/sh
rust(){
  rustc $1 --out-dir `dirname $1` | `echo $1 | sed 's/\.[^\.]*$//'`
}

実行

% rust path/sample.rs

なんかダサイ気もしますが、いったんこんなもんで。。。

2. CodeRunnerでの設定

CodeRunner – Programming Editor for macOS

こちらのツールでの設定をご紹介します。

設定方法

  1. CodeRunner起動
  2. メニューバーの 「CodeRunner」 > 「Preferences」 > 「Languages」 > 「Rust」 を選択
  3. 「Run Command:」 に、以下記述をする
RunCommand
rustc $filename | ./$compiler

スクリーンショット 2020-04-08 13.36.54.png

実行

実行ボタンをポチる

0
0
4

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?