Module auto-imported

prelude

The prelude is imported into every file for you, so nothing here needs a use. It holds the types almost every program touches: Option and Result for values that may be missing or may have failed, Vec for growable lists, the Range types behind a..b, and the Iterator traits that for x in loops are built on.

Operator traits live in prelude::ops and float math in prelude::math; both are auto-imported too. The primitive types (int, string, …) are listed under types.

Built into the compiler.

Modules#

ModuleDescription
prelude::opsOperator traits (Add, Eq, Ord, Show, …): implement them to use operators on your types.
prelude::mathFloat math (sqrt, sin, ln, …) and small linear algebra (dot, cross, matmul, Matrix). Auto-imported.

Types#

NameDescription
OptionAn optional value: either Some(value) or None.
ResultThe outcome of an operation that can fail: Ok(value) or Err(error).
VecA growable, heap-allocated vector of T values.
RangeA lazy half-open range start..end: every value from start up to, but not including, end.
RangeInclusiveA lazy inclusive range start..=end: every value from start up to and including end.

Traits#

NameDescription
IteratorA source of values that for loops pull from one at a time.
IntoIteratorA type that can be turned into an Iterator, which makes it usable in for x in value.

Functions#

NameDescription
ordReturns the code of the single character in s as a byte.
charReturns the one-character string whose code point is b.
black_boxReturns x unchanged, through a call the optimizer cannot see into.
↑ ↓ navigate ↵ open