Reference

Programming languages

Choose TypeScript, Go, Rust or C++ and find syntax, everyday APIs, standard libraries and tools in one place.

Scope and conventions

TypeScript/Node, Go 1.23+, Rust 2024 and C++23: from a first CLI to files, JSON, HTTP, concurrency and testing. Complete programs are labeled; other examples identify their surrounding code/imports. Optional libraries and version requirements are named in each entry.

Files & dependencies

Read imports and qualified names

Rust

:: follows a module/type path. use brings names into scope; self in braces imports the module itself. Importing the Read trait enables its methods. Cargo.toml describes the package.

Fragment

Import fragment; no custom types assumed.

src/main.rs
Follow appearance
GitHub Light
GitHub Dark
Rosé Pine
Catppuccin Mocha
VS Code Dark+
use std::io::{self, Read};

// io::stdin() uses the module name.
// Read supplies read() on a stdin lock.

Read public and private boundaries

Rust

Items are private by default under Rust’s module rules. pub exposes an item along an accessible module path; pub(crate) limits visibility to the crate. Public types can still have private fields.

Fragment

Fragment: imports and type/function declarations at file scope; usage statements inside a function.

src/main.rs
Follow appearance
GitHub Light
GitHub Dark
Rosé Pine
Catppuccin Mocha
VS Code Dark+
pub struct Place {
    pub name: String,
    note: String,
}

pub(crate) const DEFAULT_NAME: &str = "north";

Split code across local files

Rust

mod declares a module; mod names; can load names.rs beside the parent module file. use introduces a path into scope. A crate is a compilation unit; a module is a namespace inside it.

Fragment

Two complete source files in one Cargo binary package.

src/main.rs
Follow appearance
GitHub Light
GitHub Dark
Rosé Pine
Catppuccin Mocha
VS Code Dark+
// src/names.rs
pub const NAME: &str = "north";

// src/main.rs
mod names;

fn main() {
    println!("{}", names::NAME);
}

Recognize manifests and compiler configuration

Rust

Cargo.toml describes the package, edition and dependencies; Cargo.lock records resolved versions. Rust’s edition is separate from the installed compiler version. Binary source normally starts at src/main.rs.

Fragment

Cargo.toml fragment; Rust 2024 edition requires Rust 1.85 or newer.

src/main.rs
Follow appearance
GitHub Light
GitHub Dark
Rosé Pine
Catppuccin Mocha
VS Code Dark+
[package]
name = "guide"
version = "0.1.0"
edition = "2024"

Recognize dependency commands

Rust

std is supplied by the Rust toolchain. cargo add records a dependency in Cargo.toml; use brings a path into scope. Dependency features and versions belong to the project’s manifest.

Fragment

Illustrative shell command only; cargo add is built into Cargo 1.62+. No dependency is installed by this reference.

src/main.rs
Follow appearance
GitHub Light
GitHub Dark
Rosé Pine
Catppuccin Mocha
VS Code Dark+
# In a Cargo package:
cargo add serde