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.
:: 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.
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.
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.
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.
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.