Level 0 · Foundations

Standards & Conventions 📏

Code is read far more often than it is written. The industry's conventions exist so that any programmer can open any project and feel at home. Learn them early and your code looks professional from day one.

Why conventions matter

Imagine a library where every shelf used a different sorting system. That is a codebase without conventions. Conventions are not bureaucracy; they are kindness to the next reader, and the next reader is usually you, three months from now, at midnight, hunting a bug.

Naming things 🏷️

Different languages chose different casing styles, and each community treats its choice as law. Rust's rules:

ThingStyleExample
variables & functionssnake_caseplayer_score, calculate_tip
types (structs, enums, traits)UpperCamelCasePlayerScore, TrafficLight
constantsSCREAMING_SNAKE_CASEMAX_PLAYERS
crates & filessnake_case or kebab-casemy_game, rusty-school

Beyond casing: names should say what a thing is or does. days_until_launch beats d. The compiler does not care. Humans care enormously.

Formatting: let the robot do it 🤖

Where do braces go? Tabs or spaces? Programmers wasted decades arguing. The modern answer: an auto-formatter rewrites your code into the community's one agreed style, and everyone moves on with their lives. In Rust:

cargo fmt      # reformat the whole project, perfectly, in a second
cargo clippy   # the linter: flags working-but-unidiomatic code and explains better ways

A linter like clippy goes beyond layout: it spots patterns that work but smell ("you wrote a loop where .sum() would do"). Treat clippy as a free senior colleague. Run both before every commit and your code reviews will be about ideas, never about commas.

Semantic versioning: what 1.4.2 means 🔢

Software versions look like MAJOR.MINOR.PATCH, and the numbers are a promise called semver:

A 0.x version means "still finding its shape, anything may change." When Cargo lists rand = "0.9" in Cargo.toml, this grammar is what the numbers speak. Rust itself takes the promise unusually seriously: code that compiled on Rust 1.0 in 2015 still compiles today.

Documentation: the README and friends 📖

Every project's front door is a README file: what this is, how to run it, how to help. Beyond that, Rust has documentation comments: write /// above a function and cargo doc builds a documentation website from your comments automatically. The beautiful std library docs you will use daily are generated exactly this way. Rule of thumb: document why, let the code say what.

Licenses: the legal layer of open source ⚖️

Public code is not automatically free to use; the license file grants permission. You mostly need to recognize three families:

🔍 A live example: this very school The Rusty School practices what this lesson preaches. Its code is dual-licensed MIT OR Apache-2.0 (the Rust custom you just learned), and the course text uses a Creative Commons license (CC BY-NC-SA: credit required, no commercial use, adaptations stay open). Every code example you copy from these lessons is MIT/Apache, so it is yours to use in any project. Check the repo's LICENSE files to see how a real split looks.

The three-letter philosophies 🧭

You will hear these acronyms in every code review of your life:

💡 Held loosely These are guardrails, not commandments, and they even conflict at times (deduplicating too aggressively can violate KISS). Experienced engineers quote them, then use judgment. You will develop that judgment by building.
Exercise 1

Fix the names

These compile but break Rust convention. Correct each one: let PlayerHealth = 100; · fn CheckCollision() {} · struct game_state {} · let max_retries_constant = 3; (it never changes)

Reveal solutions

let player_health = 100; · fn check_collision() {} · struct GameState {} · const MAX_RETRIES: u32 = 3;. Bonus: the Rust compiler actually warns about most of these. Convention is built into the tools.

Exercise 2

Read the version tea leaves

Your project depends on serde 1.0.219. For each new release, decide: update casually, or read the changelog first? (a) 1.0.220 · (b) 1.1.0 · (c) 2.0.0 · (d) a different crate at 0.3.1 → 0.4.0

Reveal answers

(a) patch: update casually. (b) minor: safe, skim the new features for fun. (c) major: read the migration notes before touching it. (d) 0.x minor bumps may break by convention: treat like a major, read first.

Exercise 3

Audit a real project

Open any popular Rust repo on GitHub (try rust-lang/rustlings). Find its README, its LICENSE (which family?), its version number, and one /// doc comment in the source. Five minutes of detective work.

Reveal what you will find

Rustlings: a thorough README with setup steps, dual MIT/Apache-2.0 licensing (the Rust custom), a semver version in Cargo.toml, and doc comments throughout the source. Every convention from this lesson, live in the wild.