Skip to content

Lab · Rust Programming

Lab: a price board for a chai stall

Labbeginner· about 1 hour· 5 steps

The brief

Sharma Chai Stall in Pune wants a tiny program that prints its price board and adds up the day's sales. You check your Rust install, create the project with cargo, print the board with placeholders, read your first compiler error, fix it with mut, use constants and shadowing, and finish with a fast release build.

Why it matters

Every Rust job starts with the same loop: cargo new, edit, cargo run, read the compiler message, fix, run again. Doing it on a small real program makes the loop automatic, and reading the error codes calmly is the habit that separates people who enjoy Rust from people who give up.

Skills you practise

  • rustc and cargo versions
  • cargo new and cargo run
  • println! with {} and {name}
  • let, mut and error E0384
  • const and shadowing
  • cargo run --release

You need

  • Rust stable installed with rustup (rustup.rs), or the Rust Playground for steps 2 to 4
  • A terminal and an editor (VS Code with rust-analyzer is ideal)

What you will have at the end

A chai_stall cargo project whose src/main.rs prints the price board and the day's sales, plus a release build in target/release.

How it is marked (rubric, 100 points)
Correct outputEvery line matches: prices, the combo, 42 cups, Rs 420 and both true checks.40
Rust basics used wellconst with types, mut only where a value changes, shadowing for the cash text, {name} placeholders.30
Reads compiler messagesCan point to the "first assignment" and "help" lines of E0384 and explain the fix.20
Clean buildThe release build has no warnings.10

0/5 steps done

Step 1 of 5

Check Rust and create the project

rustc prints its version and cargo has created the chai_stall project.

First make sure Rust is installed: rustc --version prints the compiler version. Then cargo new makes a folder with Cargo.toml (the project settings) and src/main.rs (your code). Run both commands in the folder where you keep your projects, and paste everything they print. Then cd chai_stall for the rest of the lab.

Run this on your machine, then paste the output below
$ rustc --version; cargo new chai_stall

Also check yourself

Your notes: src/main.rs

Write down each command you ran. It goes into your project summary.