One crate, one job
A crate is a Rust package you can reuse. Use it when it saves boring work, like parsing CLI flags, reading dates, or making coloured output.
Do not add crates because they look popular. For your internship repo, you should be able to explain why each dependency exists.
What Cargo does
Cargo reads your Cargo.toml file, downloads dependencies, builds them, and records exact versions in Cargo.lock.
For an app or CLI project, commit Cargo.lock. It helps another builder, mentor, or recruiter run the same dependency versions you used.
Choose a crate
Do each one yourself, then tap it to tick it off. The ticks are only a checklist for you: they are not marked or scored.
0 of 5 done
Add clap
clap is commonly used for parsing command-line arguments. Here is a small setup for a todo-style CLI.
This example keeps the dependency simple. It uses clap with its derive feature.
# Cargo.toml
[package]
name = "rust-todo-cli"
version = "0.1.0"
edition = "2021"
[dependencies]
clap = { version = "4.5", features = ["derive"] }Use the crate
This code lets your CLI accept an action and a task. The pattern matching is still your code. The crate only handles argument parsing.
Run it with cargo run -- add "pay hostel mess bill".
use clap::{Parser, Subcommand};
#[derive(Parser)]
#[command(name = "todo")]
#[command(about = "A small task CLI")]
struct Cli {
#[command(subcommand)]
command: Command,
}
#[derive(Subcommand)]
enum Command {
Add { task: String },
Done { id: u32 },
}
fn main() {
let cli = Cli::parse();
match cli.command {
Command::Add { task } => println!("Added task: {task}"),
Command::Done { id } => println!("Marked task #{id} as done"),
}
}Do not paste blindly
AI tools are useful for crate setup, but they often mix old syntax with new versions. Ask for the crate version you use, then check the official docs and run cargo check.
Also check that the generated code fits your project. If AI adds async, databases, or five extra crates for a simple CLI, remove the extra parts.
Keep updates controlled
When something breaks after adding a crate, read the first compiler error before changing code. Rust errors usually point to the wrong type, missing import, or missing feature flag.
Use cargo tree when your project feels heavy. It shows all dependency packages pulled in by your crates.
cargo check
cargo treeDo this now
Do each one yourself, then tap it to tick it off. The ticks are only a checklist for you: they are not marked or scored.
0 of 5 done