Skip to content

🚀 Hello, Cargo! ✨

Compare
Choose a tag to compare
@mohammadzainabbas mohammadzainabbas released this 09 Jan 03:22
· 1527 commits to main since this release

Hello World (with Cargo)

Rust Badge Rust Report Card MIT License

Overview

A tutorial for  
 Hello World!
 
based program built via Cargo: a Rust’s build system and package manager.

Tip

This tutorial is based on Rust Book and Rust By Example.

Key Concepts

  • Create new binary project using cargo new hello-world
  • Build & run the project using cargo run

Prerequisites

  • Rust (stable, with cargo installed)

Quick Start

Setup

  1. Create a new binary project using cargo new hello-world:
cargo new hello-world

or

cargo new hello-world --bin

Note

By default, cargo new creates a binary (application) template. You can use --bin flag to explicitly specify it.

  1. Build & run the project using cargo run:
cd hello-world
cargo run

Tip

Run cargo run --help or cargo help run to see detailed options of cargo run command.

You should see the following output:

    Finished dev [unoptimized + debuginfo] target(s) in 0.04s
     Running `target/debug/hello-world`
Hello, world!

Important

cargo run compiles/builds the code and then run the resultant executable all in one command.

Full Changelog: https://github.com/mohammadzainabbas/rust-from-dust/commits/v1.0