Skip to content

Gossamer language reference

One page per language feature. Source is crates/gossamer-std/src/manifest/feature_status.rs; this index is regenerated from manifest::FEATURE_STATUS by gos doc --emit-stdlib.

Feature Summary
Built-in traits Every trait an impl header or a bound may name without declaring it.
lang::let Immutable binding.
lang::let_mut Mutable bindings can be reassigned and can be the source of &mut.
lang::if Conditional expression.
lang::match Exhaustive pattern match expression.
lang::if_let Single-variant pattern sugar.
lang::while_let Loop that drains while a pattern matches.
lang::for Iterator-driven loop.
lang::loop Unconditional loop with break value.
lang::break Exit the innermost loop, optionally with a value.
lang::continue Skip to the next iteration of the innermost loop.
lang::return Exit the enclosing function with a value.
lang::question_mark Short-circuit Result / Option propagation operator.
lang::pipe Forward-pipe operator |>, for composing free functions in a functional style. A step is either a bare callable (x |> f) or a closure whose parameter is the piped value (x |> |v| f(a, v)). Methods chain on their own and are the shorter spelling; a method chain can feed a pipe.
lang::closure Lambda expression |args| body.
lang::callback_shorthand A callback written without |v|: a std free function named in value position stands for the closure that calls it, as in xs.map(math::abs).
lang::fn Function declaration.
lang::struct Product type declaration.
lang::enum Sum type declaration with payload-carrying variants.
lang::trait Behaviour interface declaration.
lang::impl Inherent and trait implementation blocks.
lang::generics Type and const parameters on functions, impls, structs, and enums. A const parameter is a value inside the item that declares it (N as i64, [0; N]), taken from an array argument's length, a turbofish, an array field or payload, or the type the context expects.
lang::wrapping_arithmetic Wrapping arithmetic operators +%, -%, *% and their compound forms +%=, -%=, *%=: two's-complement wrapping at the operands' declared integer width, on every tier and in every build profile. Plain +, -, and * keep their overflow check, and wrapping_add / wrapping_mul are not methods (GT0087).
lang::simd Fixed-width lane vectors: Simd<T, N> over i8 through u64, f32, or f64 and its bool form Mask<N>. Lane-wise arithmetic and bitwise operators, saturating and fused operations, lane comparisons, bitmasks, conversions, shuffles, select, reductions, gathers, and windows over a sequence, with the same bits on every tier (GT0089).
lang::cohort Structured concurrency: cohort { } owns the goroutines spawned inside it, joins them on every exit path, and reports the first failure as its Result.
lang::interpolated_string f"..." string literal whose {expr} / {expr:spec} placeholders render any expression, with format's specs: f"{xs.len()} items, {total:.2}".
lang::triple_quoted_string """ string literal whose body is dedented by the indentation it shares with its closing delimiter; gos fmt moves the block with the line that opens it.
lang::select Channel multiplex select expression.
lang::channel Typed channel via std::sync::channel.
lang::weak_references Weak<T> downgrade/upgrade handles. downgrade pins its referent for the scope that took it and aggregate stores copy, so a weak never observes a member of a reference cycle and upgrade answers the same on every tier whenever cycles are collected.
lang::spawn Goroutine spawn: spawn(f) -> JoinHandle<T>, .join() -> Result<T, String>. The child attaches to the cohort { } the call is written inside, which every spawn outside main must have (GT0086), so nothing is detached and nothing is attached by accident.
lang::builtin_calls The compiler-known call names, written without a sigil: the format family (print/println/eprint/eprintln/format/panic), the desugaring calls (matches/todo/unimplemented/unreachable/dbg), and codegen. The set is closed and there are no user-defined macros.
lang::doctest Fenced code in // doc comments runs under gos test.
lang::cfg Conditional compilation attribute, resolved for the target a build produces (gos build --target, gos check --target) rather than the host; feature = "name" reads the declaring package's [features], and #[cfg] applies to a use too.
lang::unsafe_extern unsafe extern "C" { fn strlen(text: [u8]) -> usize } declares C functions, called inside unsafe { } (GT0097), and type Name declares a C type reached only as ffi::Ptr<Name> (GT0104). Parameters are scalars, ffi::Ptr and Option<ffi::Ptr>, out-parameters (&mut a scalar or pointer), C function pointers written Fn(..) -> R and filled with a named function, slices of scalars or structs, and #[repr(C)] structs and ffi::Unions by value; results are scalars, pointers, and structs (GT0098). #[export] makes a free function a C symbol (GT0113), [lib] kind builds a C library and header from the exports, and [native] compiles a package's own C sources. std::ffi reads and writes foreign memory by copy inside unsafe (GT0103), allocates from the C allocator, and holds callback context in ffi::Handle. Every call is foreign and unsafe whatever it does, clears and captures errno for ffi::last_errno() and ffi::last_os_error(), and when it blocks lets another worker start the goroutines waiting on its own; #[link(name, search)], #[link_name], and #[cfg] choose the library, symbol, and platform. A project refuses native code with ffi = false in project.toml (the default is true), and then a declaration in the project or a dependency is GT0102.
lang::attribute Built-in attributes (#[cfg], #[test], #[bench], #[derive]).
lang::const Compile-time constant binding.
lang::static Module-level mutable or immutable static slot.
lang::opaque_nominal_alias type Name = new Repr declares a distinct nominal type over an unchanged runtime representation, erased before lowering so no tier sees one. It inherits equality, ordering, hashing, and formatting - which describe the value both sides share - and nothing else: arithmetic needs the alias's own impl Add, and the representation's methods are not in scope. .into() converts to and from its own representation; any other pair needs impl From.
lang::slicing A range in index position takes a subsequence: xs[1..3], xs[..k], xs[k..], xs[..], xs[a..=b], over fixed arrays, slices, Vec, and String. Bounds clamp rather than panic, matching substring; a String slice takes byte offsets and snaps to codepoint boundaries.
lang::visibility Three visibilities: private by default (the declaring module and its descendants), pub(package) (every module of the declaring package), and pub (the package's public API). Declared per item, per method, and per struct field; pub(crate) / pub(super) / pub(in path) are rejected (GP0038).
lang::type_alias Transparent type alias: type X = T (and generic type Pair<A> = (A, A)) is interchangeable with its target everywhere; a cyclic alias is rejected (GT0024).
lang::mut_ref_params Local &mut aliases write through; &mut Vec<T> / &mut [T] parameters write through on every tier.
lang::unicode_identifiers Identifiers follow UAX #31 (matches Rust 2024).
lang::comptime Zig-style compile-time evaluation: comptime { ... } blocks, comptime fn calls, and comptime parameters run on the bytecode VM during compilation and fold to a literal, so every tier compiles the identical constant. typeInfo::<T>() reflects a struct's fields, a tuple struct's positions, or an enum's variants - substituting the arguments for a generic instantiation - and a for (name, ty) in typeInfo::<T>() loop unrolls into native per-field code, and codegen(...) splices a comptime fn's String back as source. Includes the regex::compile / sql::statement build-time literal validation.
lang::keyword_arguments Keyword arguments and parameter defaults: a call may name any parameter (volume(depth: 4, width: 2)), and a parameter may declare a default known while compiling (fn volume(width: i64, height: i64 = 2), mode: Mode = Mode::Fast, parent: Option<Window> = None) that is spliced into every call omitting it, meaning what it means where the function is declared. Positional arguments come first, then names. Both are caller-side spellings rewritten into the callee's declared order before type checking, so the calling convention is unchanged. A name on a method call is matched when every type declaring that method name would rewrite the call identically; when they disagree the call is reported (GR0013) rather than guessed.
lang::move_keyword move closure capture keyword - declined permanently (SPEC 17.5). Capture is automatic and the runtime manages ownership, so move would annotate a decision the language does not make.
lang::async_await async fn / .await - declined permanently (SPEC 17.5). Goroutines and channels cover the same shape without colored functions.
lang::lifetimes Explicit lifetime annotations and a borrow checker - declined permanently (SPEC 17.5). References have implicit lexical lifetimes ending at the closing brace, and the lexical &mut check is the intended ceiling.