πŸ€–
World 1 Β· Hello, Rust!

Cargo, Your Robot Helper

Imagine having a helpful robot that sets up your projects, gathers everything you need, and runs your code for you. In Rust, that robot is called Cargo! πŸ€–

The Big Idea Cargo is Rust's helper tool. It can make new projects, build them (turn your words into a program), and run them β€” all with short, friendly commands.
Think of it like this… Cargo is like a kitchen helper. You say "I want cookies," and it grabs the ingredients, mixes the dough, and bakes them. You just enjoy the results! πŸͺ

Making a new project

To start a fresh project, you type one command in the Terminal. Let’s make one called hello:

cargo new hello

Cargo builds a whole folder for you, all neat and tidy, with a starter program already written inside. That saves you a lot of setup!

Running your project

Now you go into your project and tell Cargo to run it:

cargo run

Cargo builds your code and runs it, all in one step. Here’s the program Cargo wrote for you inside the file main.rs β€” press β–Ά Run to see what it does:

That’s the same friendly hello you already know β€” and Cargo set it up for free! πŸŽ‰

The little settings file: Cargo.toml

Inside your project, Cargo also makes a file called Cargo.toml. It’s a tiny settings file that holds your project’s name and other details.

New word Cargo.toml is your project's settings card. It tells Cargo the project's name and what extra tools it might need.
Ferris says: You'll mostly use just two commands at first: cargo new to start, and cargo run to build and run. Simple as that! πŸ¦€
Try this! Type cargo new hello in the Terminal, then go into the folder and type cargo run. Watch your robot helper say hello!

Quick quiz

What does the command cargo run do?

That's right! cargo run builds and runs your program in one easy step.

You learned… Cargo is your robot helper: cargo new hello makes a project, cargo run builds and runs it, and Cargo.toml is the project's settings file. You've finished World 1 β€” next world, we start playing with words and numbers! 🎈