An introduction into Rust. Part 2: Building and Running, Creating a Package, Numerical Operations

3 min readJan 7, 2022

Welcome back to the follow-up of the introduction into Rust! This post is all about to get your first Rust program built and executed.

You can follow the code examples on your local machine by ensuring Rust has been successfully installed as described in the previous post.

Running the first program:

Running the first code in Rust can be as easy as just going to this website: This is Rust’s playground that lets you quickly check out short code snippets.

In order to compile and run Rust code locally, you already have installed everything necessary if you followed the section ‘Installation’.

  1. create some folder: mkdir my-first-rust
  2. cd my-first-rust
  3. add a file named
  4. add the following content to
fn main() {
println!("Hello, world!");

5. run the compiler: rustc

6. execute the compiled resource: ./main or ./main.exe

This should print Hello World to the terminal.

Packaging with cargo:

Although the above approach is absolutely valid, it is recommended to use the package manager cargo to create and run your Rust project. This comes with many advantages like dependency management, automatic tests, …

To create a new Rust project you would just run in a terminal:

cargo new my-rust-project

This creates a folder my-rust-project where you find a file named Cargo.toml. This is similar to the well known package.json if you come from JavaScript. It’s contents looks like:

name = “my-rust-project”
version = “0.1.0”
edition = “2021”




I am a Software Developer - Java, Rust, SQL, TypeScript - with strong interest doing research in pure and applied Mathematics.