Read common type names
#i32/u32 are signed/unsigned 32-bit integers; usize indexes sizes. String owns UTF-8 text; &str borrows it. [0_u8; 3] repeats a typed byte three times. Vec<T> is growable.
Fragment
Fragment inside a function.
Reference
Choose TypeScript, Go, Rust or C++ and find syntax, everyday APIs, standard libraries and tools in one place.
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.
i32/u32 are signed/unsigned 32-bit integers; usize indexes sizes. String owns UTF-8 text; &str borrows it. [0_u8; 3] repeats a typed byte three times. Vec<T> is growable.
Fragment
Fragment inside a function.
:: selects a path; ::<T> supplies a generic type. & borrows; &mut borrows mutably. ! after a name invokes a macro. [..n] excludes n. Single quotes denote a char; double quotes denote text.
Fragment
Fragment; shared borrow ends before mutation.
Option<T> is either Some(value) or None. A normal &T reference is not nullable. Use pattern matching or Option methods instead of assuming a value is present.
Fragment
Fragment: imports and type/function declarations at file scope; usage statements inside a function.
struct defines a named record. Field names can use shorthand when a local name matches. Mutating a field requires a mutable binding/access path; pub controls external visibility.
Fragment
Fragment: imports and type/function declarations at file scope; usage statements inside a function.
Tuple elements can have different types. A pattern unpacks them; .0, .1, etc. access positions directly. A one-element tuple needs a trailing comma, such as (24,).
Fragment
Fragment: imports and type/function declarations at file scope; usage statements inside a function.
An enum names alternatives; each variant can carry different data. match checks exhaustiveness. A plain mode enum and a payload-carrying reply use the same enum mechanism.
Fragment
Fragment: imports and type/function declarations at file scope; usage statements inside a function.
A type parameter appears in angle brackets; trait bounds specify available behavior. Many type arguments are inferred. ::<T> explicitly supplies a generic argument at a call site.
Fragment
Fragment: imports and type/function declarations at file scope; usage statements inside a function.
A trait declares behavior; impl Trait for Type supplies it explicitly. Trait bounds allow static dispatch; &dyn Trait can request dynamic dispatch for compatible traits.
Fragment
Fragment: imports and type/function declarations at file scope; usage statements inside a function.
as performs supported casts, including potentially lossy numeric casts. TryFrom/TryInto make fallible conversion explicit with Result. Ordinary static types do not use TypeScript-style runtime narrowing.
Fragment
Fragment: imports and type/function declarations at file scope; usage statements inside a function.