std/core
What every other package builds on: the types the language itself refers to - Option behind Value?, Result
behind ?, Range, RangeFrom and RangeTo behind a..b, Array as the inline storage a list literal adapts to -
the traits the operators
and the conversions go through, and the control flow that is a function.
Nothing here knows about text, numbers or collections, which is what makes it the bottom of the standard library -
with the one exception that String is unavoidable in a signature (Show.show, panic). That import points at
std/text and is the reason the standard library's packages are cyclic; see "Modules and Packages" in CONCEPT.md.
Modules
std/core/array[Array], the inline storage primitive: a fixed number of items whose count is part of the type instead of its storage.std/core/bool[Bool],trueandfalse: the primitive thatif,while,&&,||and!are built on directly, without going through a trait method the way+goes throughAdd.std/core/compareEquality, order and hashing: [Equals], [Ordering], [Compare] and [Hash], generated structurally for everytypeunless it implements one of them by hand, andcombineHashes, what a hand-writtenhashfolds its parts through.std/core/controlControl structures that are ordinary functions.std/core/convertConversion between types: [From]/[Into] for a conversion that always works, [TryFrom]/[TryInto] for one that can fail.std/core/error[Error], the trait-typed failure that lets an application pass a reason up through layers that have nothing to say about it, and its one member:cause, the chain to whatever error caused this one.std/core/functionsNames for the three closure shapes that signatures take most: a question about one value, an effect on one value and a conversion of one value into another.std/core/operatorsAdd,Subtract,Multiply,Divide,Remainder,PowerandNegate, the traits the arithmetic operators go through, plusOrElsefor??andIndexed/MutableIndexed/Slice/MutableSlicefora[i]anda[from..to].std/core/optionAbsence as a value: [Option], its two cases, and the vocabulary that works on the value that is there.std/core/rangeThe three ranges the syntax writes - [Range] for0..10, [RangeFrom] for0.., [RangeTo] for..10- the trait [Bounds] that reads any of them, and [RangeIterator], what it takes to walk a range of integers.std/core/resultFailure as a value: [Result], its two cases, and the vocabulary that works on the value of a successful one.std/core/sharedAtypeis a value: assigning it, passing it and capturing it is a copy.std/core/targetWhat a program is compiled for: [OperatingSystem], [Architecture] and [ByteOrder], each with onestatic current.std/core/void[Void], the result of a function that says nothing, [Never], the type of an expression that never produces a value, andpanic, which is how a bug ends a program instead of returning one.
Everything
- alias
ActionA closure called for its effect on one value, with nothing to return: whatforEachtakes. - trait
Adda + b. - type
ArchitectureThe processor architectures the toolchain builds for. - type
ArrayA fixed number of items, and the number is part of the type:Array<Float, 16>. - extend
Array<Item, Size> with EqualsEqual when the items at the same index are equal. - extend
Array<Item, Size> with ShowThe items in brackets, like a [List]: the size is in the type and would say nothing a reader cannot count. - extend
Array<Item, Size> with HashOrder-dependent, like [List.hash]: anArrayis an ordered sequence. - type
Booltrueandfalse, and nothing else. - trait
BoundsWhat every range has in common: the two ends, eachNonewhere the range is open on that side. - type
ByteOrderThe order of the bytes of a number in memory, for a binary format that says "native order". - trait
CloseThe destructor of an object: what releases the resource behind it - a descriptor, a socket, a lock - once nothing holds the object any more. - fn
combineHashesFolds one more value into a running hash: wrapping, order-dependent, and deterministic across runs and platforms. - trait
Compare<,<=,>,>=. - trait
Dividea / b. - fn
doEvaluates a block immediately:const x = do { ... }. - trait
Equals==and!=. - trait
Error"Some error, hand it up."Result<Value, Error>is the trait-typed failure: every error type that carries this trait fits into it, so an application can pass a failure up through layers that have nothing to say about it without declaring a wrapper type per layer. - trait
FromInfallible conversion. - trait
HashGenerated structurally for everytype. - trait
Indexeda[key]. - trait
IntoThe other direction of [From], gained for free whereverTarget: From<Self>. - fn
isSametrueif both are the same object. - type
LiteralParseErrorWhatStatus.tryFrom(text)fails with whentextis not one of a literal type's members: - trait
Multiplya * b. - trait
MutableIndexeda[key] = value. - trait
MutableSlicea[from..to] = values. - trait
Negate-a. - type
NeverThe type of an expression that does not return:panic,return,break,continue. - type
OperatingSystemThe operating systems the toolchain builds for. - type
OptionA value that may be absent. - extend
Option<Value> with ShowSome(value)or the bareNone- a case with fields is written out, a case without one is its name. - extend
Option<Target> with From<Iterate<Value?>>All or nothing:names.map(findUser).to<List<User>?>()isSome(users)if every user was found. - type
OrderingWhat [Compare.compare] answers: which of the two values comes first, or that neither does. - trait
OrElsea ?? b: the value, or the fallback where there is none. - fn
panicFor bugs. - trait
Powera ** b:araised to the power ofb. - alias
PredicateA closure that answers a yes-or-no question about one value: whatfilter,find,anyandtakeWhiletake. - type
Range0..10,0..=10: a range with both ends. - extend
Range<Value> with Bounds<Value>Both ends are there, andinclusivesays whether the high one is inside. - extend
Range<Int> with Iterate<Int>, LengthA range of integers with both ends is a sequence with a length. - extend
Range<Value> with ShowThe source form, and not the fields:0..10,0..=10. - type
RangeFrom0..: a range with a start and no end. - extend
RangeFrom<Value> with Bounds<Value>Open at the end, so there is no high end to include. - extend
RangeFrom<Int> with Iterate<Int>0..counts on forever, which is what makesfor index in 0..and(0..).take(3)work. - extend
RangeFrom<Value> with Show0.., the source form. - type
RangeTo..10,..=10: a range with an end and no start. - extend
RangeTo<Value> with Bounds<Value>Open at the start. - extend
RangeTo<Value> with Show..10,..=10, the source form. - trait
Remaindera % b. - type
ResultThe result of an operation that can fail:Okwith the value, orFailwith the reason. - extend
Result<Value, Failure> with ShowOk(value)orFail(failure). - extend
Result<Target, Failure> with From<Iterate<Result<Value, Failure>>>All or the first error:lines.map { text => Int.tryFrom text }.to<Result<List<Int>, NumberParseError>>()Stops pulling at the firstFail. - fn
retryconst response = retry 3 { http.get(url) }. - type
SharedA box that puts a value in a place several owners can hold, without declaring a wholeshared typefor it. - trait
ShowUsed by string interpolation. - trait
Slicea[from..to]. - extend
Source with Into<Target> where Target: From<Source>The blanket implementation that gives every [From] its [Into] for free: nothing implementsIntoby hand. - extend
Source with TryInto<Target, Failure> where Target: TryFrom<Source, Failure>The blanket implementation that gives every [TryFrom] its [TryInto] for free: nothing implementsTryIntoby hand. - trait
Subtracta - b. - extend
Target with From<Never>Every type can be made from aNever, because there is no value to make it from:Nevercoerces to anything, so the body is the argument. - alias
TransformA closure that turns one value into another: whatmaptakes, and the key ofsortedandgroupBy. - trait
TryFromFallible conversion: the [From] for a source that may not represent a valid value. - trait
TryIntoThe other direction of [TryFrom], gained for free whereverTarget: TryFrom<Self, Failure>. - fn
unlessRuns the block unless the condition holds:if !condition { ... }, for a guard that reads better negated. - type
VoidThe type with exactly one value, and that value is the keyword literalvoid- astrueandfalseare the values ofBool.