[LINUX] Compile and run Rust with a single command

It is a partial excerpt of the following article and + α.

I learned Rust from 0 ~ Part.0 Preparation / Overview ~ --Yuto Hongo Portfolio


It is assumed that the Rust compiler has been installed and the path has been set for use on a Mac.

1. Prepared as a shell script function

Processing content

  1. Save the compiled executable in the same location as the .rs file
  2. Run the compiled file

script

bash:.bashrc and.bash_profile etc.


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

Run

% rust path/sample.rs

I feel like it's not good, but once it's like this. .. ..

2. Settings in CodeRunner

CodeRunner – Programming Editor for macOS

Introducing the settings with this tool.

Setting method

  1. Start CodeRunner
  2. Select "Code Runner"> "Preferences"> "Languages"> "Rust" from the menu bar
  3. In "Run Command:", write the following

RunCommand


rustc $filename | ./$compiler

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

Run

Click the execute button

Recommended Posts

Compile and run Rust with a single command
Build a local server with a single command [Mac]
Create applications, register data, and share with a single email
Delete all libraries installed on pip with a single command
Build a detonation velocity website with Cloud Run and Python (Flask)
Replace the directory name and the file name in the directory together with a Linux command.
A memo with Python2.7 and Python3 on CentOS
Run a Python web application with Docker
Implement a model with state and behavior
Put Docker in Windows Home and run a simple web server with Python
Source compile Apache2.4 + PHP7.4 with Raspberry Pi and build a Web server --2 PHP introduction
Source compile Apache2.4 + PHP7.4 with Raspberry Pi and build a Web server ―― 1. Apache introduction
Until you install Python with pythonbrew and run Flask on a WSGI server
Build a TensorFlow development environment on Amazon EC2 with command copy and paste
Connect Scratch X and Digispark with a bottle
Building a python environment with virtualenv and direnv
Build a virtual environment with pyenv and venv
Launch a web server with Python and Flask
Let's write a Python program and run it
Rename and move files (directories) with mv command
Source compile Apache2.4 + PHP7.4 with Raspberry Pi and build a web server --3. Use MySQL
Until you create a machine learning environment with Python on Windows 7 and run it
Run a machine learning pipeline with Cloud Dataflow (Python)
Try to make a command standby tool with python
Build a python virtual environment with virtualenv and virtualenvwrapper
Create a native GUI app with Py2app and Tkinter
Let's make a simple game with Python 3 and iPhone
Fill the background with a single color with OpenCV2 + Python
Create a batch of images and inflate with ImageDataGenerator
I made a LINE BOT with Python and Heroku
Build a python virtual environment with virtualenv and virtualenvwrapper
Let's make a Mac app with Tkinter and py2app
Create a 3D model viewer with PyQt5 and PyQtGraph
Run a Python file with relative import in PyCharm
Take a look at profiling and dumping with Dataflow
I want to run a quantum computer with Python
[Linux] Create a self-signed certificate with Docker and apache
Build a numerical calculation environment with pyenv and miniconda3
Give the history command a date and time and collect the history files of all users with a script