Part 01 · Rust Is Not Scary
Set Up Rust in 10 Minutes
এক command এ Rust install, editor setup, আর শুধু কিছু try করতে চাইলে browser এই code চালানো।
⏱ 15 মিনিট · Station 1 / 75
Goal
এই দশ মিনিট শেষে তোমার machine এ Rust install হয়ে যাবে। Editor টা Rust বুঝবে, আর একটা project compile হয়ে run হবে। সাথে এটাও জানবে, শুধু তিন line code try করতে চাইলে কিছু install না করেই কোথায় যাবে।
তিনটা tool, প্রত্যেকটার কাজ একটা:
- rustup Rust install করে, আর update রাখে। ধরো এটা সেই দোকান যেখান থেকে toolbox টা কিনলে।
- rustc হলো compiler। তোমার
.rsfile গুলোকে এমন program বানায় যেটা computer run করতে পারে। - cargo হলো যেটা তুমি প্রতিদিন type করবে। Project বানায়, তোমার হয়ে
rustccall করে, library download করে, test চালায়। হাতেrustccall করার দরকার প্রায় কখনোই পড়বে না।
নিচের সবকিছু Ubuntu 26.04 আর Rust 1.98.1 এ run করা। নতুন version এ একই output আসবে, শুধু number টা আলাদা।
Setup
Linux and macOS
একটাই command। এটা rustup download করে। তারপর rustup তোমার home folder এ latest stable Rust install করে দেয় (sudo লাগে না):
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
Default install নিতে Enter চাপো। শেষ হলে একটা নতুন terminal খোলো (অথবা source "$HOME/.cargo/env" run করো)। না হলে shell নতুন command গুলো খুঁজে পাবে না।
Final program বানাতে Rust এর একটা C toolchain এর linker লাগে। Mac এ xcode-select --install চালালেই সাধারণত এটা চলে আসে। Ubuntu বা Debian এ একবার install করে নাও:
sudo apt install build-essential
Windows
rustup.rs থেকে rustup-init.exe download করে run করো। এটা Visual Studio C++ Build Tools চাইবে (Windows এর linker)। Install করতে দাও। তারপর একটা নতুন PowerShell window খোলো।
Check it worked
rustc --version
cargo --version
rustup --version
rustc 1.98.1 (48a229cea 2026-09-01)
cargo 1.98.1 (797e8a9bc 2026-08-05)
rustup 1.29.1 (d95a37b6a 2026-08-13)
তিনটা version line আসলে সব ঠিক আছে। পরে rustup update দিলে এক step এ newest stable Rust পেয়ে যাবে। প্রতি ছয় সপ্তাহে একটা নতুন stable version আসে, আর পুরনো code compile হতেই থাকে।
Your editor
VS Code নাও (অথবা Language Server Protocol support করে এমন যেকোনো editor), সাথে rust-analyzer extension, ID rust-lang.rust-analyzer। এটাই Rust এর official language server। এটা দিয়ে পাবে:
- type করার সময়ই compiler error এর লাল দাগ, কিছু run করার আগেই,
- প্রত্যেক variable এর পাশে ধূসর রঙে তার type (শেখার সময় খুব কাজের),
- go to definition, rename, আর auto-import।
তোমার variable এর পাশে : i32 টাইপের hint দেখলে বুঝবে rust-analyzer কাজ করছে।
Just want to try something? Use the Playground
play.rust-lang.org browser এর ভেতরেই Rust run করে। কিছু install করতে হয় না, setup ও নেই। Code paste করো, Run চাপো, output দেখো। এই lesson গুলোর ছোট example এর জন্য এটা perfect। আর কোথাও আটকে গেলে কাউকে snippet share করার জন্যও।
Walkthrough
একটা project বানিয়ে run করো। cargo new folder আর file বানায়, cargo run compile করে run করে:
cargo new hello-rust
cd hello-rust
cargo run
Creating binary (application) `hello-rust` package
note: see more `Cargo.toml` keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
Compiling hello-rust v0.1.0 (/home/you/rust-lab/hello-rust)
Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.13s
Running `target/debug/hello-rust`
Hello, world!
Cargo তোমার জন্য এই layout বানিয়েছে:
hello-rust/
├── Cargo.toml # the project's name, version and libraries
├── Cargo.lock # exact versions of libraries (created on first build)
├── src/
│ └── main.rs # your code starts here
└── target/ # build output, safe to delete
আর src/main.rs এ আগে থেকেই একটা চালু program আছে:
fn main() {
println!("Hello, world!");
}
এবার কিছু না বদলে আরেকবার run করো।
কোনো file না ছুঁয়ে আবার cargo run দিলে কী হবে?
Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.01s
Running `target/debug/hello-rust`
Hello, world!
এবার কোনো Compiling line নেই, আর 0.13s এর জায়গায় 0.01s। Cargo শুধু যেটা বদলেছে সেটাই আবার build করে।
Reading the output
Cargo যে line গুলো print করল, প্রত্যেকটার একটা মানে আছে:
Creating binary (application) package: cargo এমন একটা project বানিয়েছে যেটা run করার মতো program build করে (একে বলে binary)। আরেক ধরনের হলো library, যেটা অন্য project ব্যবহার করে। ওটা পেতেcargo new --libদিতে হয়।Compiling hello-rust v0.1.0 (...): cargo তোমার code এর উপরrustccall করেছে। নাম আর version আসেCargo.tomlথেকে।Finished `dev` profile [unoptimized + debuginfo]: এটা একটা debug build। তাড়াতাড়ি compile হয়, debugger এর জন্য extra info রাখে, কিন্তু optimize করা না। আসল fast version এর জন্যcargo build --releaseদিতে হয়। পার্থক্যটা দেখবে What Rust Is Good For lesson এ।Running `target/debug/hello-rust`: তৈরি program টা এই path এ থাকে। চাইলে সরাসরি./target/debug/hello-rustদিয়ে run করতে পারো। Run করার জন্য cargo বা Rust install থাকা লাগে না।Hello, world!: তোমার program শুধু এই একটা line ই print করেছে। এর উপরের সব cargo এর।
First cargo run | Second cargo run | |
|---|---|---|
| Compiles? | হ্যাঁ | না, কিছু বদলায়নি |
| Time | 0.13 s | 0.01 s |
| Program output | Hello, world! | Hello, world! |
Troubleshoot
error: linker `cc` not found
Linux এ প্রথম দিনের সবচেয়ে common problem এটা। Rust তোমার code compile করে ফেলেছে, কিন্তু শেষ step টায় (সব জোড়া লাগিয়ে একটা program বানানো) একটা C linker লাগে, আর সেটা install করা নেই। দেখতে এমন:
Compiling hello-rust v0.1.0 (/home/you/rust-lab/hello-rust)
error: linker `cc` not found
|
= note: No such file or directory (os error 2)
error: could not compile `hello-rust` (bin "hello-rust") due to 1 previous error
Fix: sudo apt install build-essential (Ubuntu/Debian), sudo dnf install gcc (Fedora), অথবা xcode-select --install (macOS)। Windows এ rustup-init.exe আবার run করো, আর Visual Studio Build Tools install করতে দাও।
cargo: command not found
Install ঠিকই হয়েছে, কিন্তু তোমার shell এখনো ~/.cargo/bin চেনে না। নতুন terminal খোলো, অথবা source "$HOME/.cargo/env" run করো। তাও না হলে check করো ~/.cargo/bin তোমার PATH এ আছে কিনা।
rust-analyzer কিছু দেখায় না, অথবা বলে "failed to discover workspace"
Project এর folder টাই খোলো (যেটার ভেতরে Cargo.toml আছে)। উপরের কোনো folder বা শুধু একটা file খুললে হবে না। rust-analyzer project খুঁজে পায় Cargo.toml দেখে।
প্রথম build slow
একটা project এর প্রথম build এ সবকিছু একবার compile হয়। পরের build গুলোতে শুধু যেটা বদলেছে সেটা। পরের part গুলোতে যখন library add করবে, প্রথম build এ সেগুলোও download আর compile হবে। এটা normal, আর একবারই হয়।
Takeaway
rustup Rust install আর update করে, cargo হলো প্রতিদিনের command, আর rust-analyzer type করার সময়ই তোমার editor কে compiler এর চোখ দেয়। শুরু করতে শুধু cargo new আর cargo run লাগে। আর শুধু একটা idea try করতে চাইলে Playground তো আছেই। এরপর: Rust কেন কঠিন বলে নাম কামিয়েছে, আর কেন সেই নামটা আসলে বেশিরভাগই কখন বলে সেটা নিয়ে।
Station stamp
Chapter শেষ করো
পড়া শেষ হলে Complete চাপো, progress save হবে। XP শুধু Pro তে — Pro থাকলে এই chapter এ +15 XP পেতে।
Pro নিয়ে XP পাও →