Hello World with Rust in 5 Easy Steps

Ananya JainAnanya Jain
2 min read

Introduction:

Welcome to our step-by-step guide to setting up Rust, a programming language known for its speed, safety, and modern tooling. Whether you're a seasoned developer or a coding enthusiast, Rust offers a fresh and powerful approach to programming. In this tutorial, we'll walk you through the process of setting up Rust on your system in just 5 straightforward steps. Let's dive in!

Step 1: Download Rust

To begin, visit the official Rust website https://rustup.rs/ and navigate to the download page. Click the download button from there to obtain the installation package tailored to your operating system.

You also need to download the "VISUAL STUDIO INSTALLER". You will be an option to install it in the Rust installation process. So, don't worry about that.

To ensure the installation check version of Rust and Cargo(package manager and build too for Rust)

Run commands:

rustc --version

cargo --version

Step 2: HOW TO CREATE PROJECT

Open powershell and run command:

cargo new myFirstRustProject

YOUR binary package is now created!!

THIS IS HOW YOUR VS CODE WILL LOOK LIKE...

HERE, Cargo.tomal file carries the details of project. TOMAL stands for TOM's obvious minimal language.

Step 3: NOW CREATE A LIBRARY

A library in Rust is a collection of reusable code modules and functionalities that can be imported and used by other programs.

Run command:

cargo new --lib myFirstRustLib

Step 4: Run code/project

The next step is to check compiler errors, warnings and create a target file. the command below will do all this.

Run the command:

cargo build

You can also run the command cargo check to check compiler errors and warnings this takes less time.

Now your vs code should look like this.

Step 5: Final Run!! ๐Ÿš€

Kudos this is the finale here. Now to get your "hello world", you just have to run this one command and you got it all.

Run Command:

cargo run

Congratulations! By following these 5 straightforward steps, you've laid the foundation for your Rust programming adventure. Whether you're intrigued by systems programming, web development, or anything in between, Rust's capabilities will empower you to build robust and efficient software. Get ready to explore a world of possibilities with Rust. Happy coding!๐Ÿคž

0
Subscribe to my newsletter

Read articles from Ananya Jain directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Ananya Jain
Ananya Jain