std.core
The core of the standard library, bound in every module without an import.
It holds the preamble (panic, assert, Error, Result, Box, the ranges, arrayOf),
the attributes, the operator interfaces (Equatable, Ordered, Hashable, Index,
Display, Debug, Clone), the number tower (Num, Integer, Float) with Parse, the
members of string, char and the arrays and views, the format language behind f-strings,
and the iterator protocol (Iterator, Iterable).
Examples
import std.io { println };
let n = (try? int.parse("42")) ?? 0;
println(n + 1);
let name: ?string = null;
println(name ?? "nobody");
let first = [3, 1, 2].iter().min() ?? 0;
println(first);
43
nobody
1
Types
static let, an associated type.extend, a module-level binding.lyric bench runs; also the measure it is handed.Index<int>, x[^n] counts from its end.std.math's abs and signum take; uint has neither.collect() calls the type's own fromIter.comptime if (f.type.kind == .Optional).static let), an associated type.Functions
pub extern "C" fn panic(message: string): never = "lyr_panic_message"
Ends the process with a message and a backtrace.
The report is LYR-RT0008 and the exit code 101. Its type is never, so a call stands
wherever a value is wanted and ends the path it is on.
pub inline fn assert(
condition: bool,
message: fn() -> string = () => "",
@callerExpr(condition) written: string = ""
): void
Ends the process unless condition holds.
The check is inlined at the call. The message is a lambda, assert(n > 2) { f"n = {n}" },
built only when the assertion fails.
Panics
When condition is false: LYR-RT0011, "assertion failed: " and the condition as it is
written, then the message where one is given.
pub extern "C" fn unreachable(message: string = ""): never = "lyr_panic_unreachable"
Marks a branch the program never takes.
Panics
Always, when reached: LYR-RT0012, "unreachable" and message behind it where one is given.
pub extern "C" fn todo(message: string = ""): never = "lyr_panic_todo"
Marks a place still to be written.
Panics
Always, when reached: LYR-RT0013, "not implemented" and message behind it where one is
given.
pub fn embed(path: string): uint8[]
Returns the bytes of a file of the package, read while the program compiles.
path is relative to the calling module, within the package's directory; a build reads the
file again when it changes. Only a comptime site, or what one calls, can make the call:
comptime embed("table.bin"); a call at run time is LYR-CT0004.
pub fn arrayOf<T, E :: [Error]>(n: int, f: fn(int) -> T throws E): T[] throws E
Creates an array of n elements, the element at i the value of f(i).
Every element is fresh, where [x] * n copies one value into every slot; f is called in
order, once per index.
Panics
When n is negative.
Errors
What f throws, the call throws, and the array is dropped.
pub fn blackBox<T>(x: T): T
Returns x through a point the compiler cannot see through.
What computed x is not dropped as unused, and the value that comes out is not known in
advance; for a benchmark's body, whose result nothing reads. It costs a store.
pub fn sequence<T>(body: fn() -> Coroutine<T>): Coroutine<T>
Creates a generator inline: sequence { yield 1; yield 2; }.
The trailing block is a generator lambda, and this calls it; the coroutine it makes runs nothing until it is pulled.
pub fn fields<T>(): FieldInfo[]
Returns the fields of a struct or a class that the asking code may name, in declaration order; none for any other type.
pub fn members<T>(): MemberInfo[]
Returns the functions, constants and associated types of a type's own body that the asking
code may name, in declaration order; members written in an extend block belong to that
block, not to the body.
pub fn attribute<A>(f: FieldInfo): ?A
Returns the value of the attribute A the field f carries, or null where it carries none.
f is the variable of a comptime for over fields or over a variant's payload, read in
its iteration.
pub fn variantAttribute<A>(v: VariantInfo): ?A
Returns the value of the attribute A the variant v carries, or null where it carries
none.
v is the variable of a comptime for over variants, read in its iteration.
pub fn memberAttribute<A>(m: MemberInfo): ?A
Returns the value of the attribute A the member m carries, or null where it carries
none.
m is the variable of a comptime for over members, read in its iteration.
pub fn parameterAttribute<A>(p: ParameterInfo): ?A
Returns the value of the attribute A the parameter p carries, or null where it carries
none.
p is the variable of a comptime for over a member's parameters, read in its iteration.
pub fn typeAttribute<T, A>(): ?A
Returns the value of the attribute A the declaration of T carries, or null where it
carries none.
A T written as an alias answers with the alias's own attributes, not its target's.
pub fn variants<E>(): VariantInfo[]
Returns the variants of an enum, in declaration order; none for any other type.
pub fn conformances<T>(): Type[]
Returns the interfaces T conforms to, by its list, its blocks and the parents they bring.
pub fn hasConformance<T, I>(): bool
Returns whether T conforms to I.
pub fn typeName<T>(): string
Returns T's name with its type arguments: Pair<int, string>.
pub fn isStruct<T>(): bool
pub fn isClass<T>(): bool
pub fn isEnum<T>(): bool
pub fn isInterface<T>(): bool
Constants
pub let target: Target
The target of the build: comptime if (target.os == .Windows) chooses while compiling.
A constant; a program that does not read it carries nothing of it.
pub let profile: Profile = comptime Profile { debug = buildDebug() }
The profile of the build: comptime if (profile.debug).
Extensions
extend int :: [
Equatable,
Ordered,
TotalOrder,
Hashable,
Display,
Add,
Sub,
Mul,
Div,
Rem,
Neg,
BitAnd,
BitOr,
BitXor,
BitNot,
Shl,
Shr
]
Conforms to Equatable, Ordered, TotalOrder, Hashable, Display, Add, Sub, Mul, Div, Rem, Neg, BitAnd, BitOr, BitXor, BitNot, Shl, Shr.
fn equals(o: int): bool
fn compare(o: int): ?Ordering
fn totalCompare(o: int): Ordering
fn hash<H :: [Hasher]>(&h: H): void
fn show(): string
fn showTo(out: StringBuilder): void
fn add(rhs: int): int
fn sub(rhs: int): int
fn mul(rhs: int): int
fn div(rhs: int): int
fn rem(rhs: int): int
fn neg(): int
fn bitAnd(rhs: int): int
fn bitOr(rhs: int): int
fn bitXor(rhs: int): int
fn bitNot(): int
fn shl(rhs: int): int
fn shr(rhs: int): int
extend int8 :: [
Equatable,
Ordered,
TotalOrder,
Hashable,
Display,
Add,
Sub,
Mul,
Div,
Rem,
Neg,
BitAnd,
BitOr,
BitXor,
BitNot,
Shl,
Shr
]
Conforms to Equatable, Ordered, TotalOrder, Hashable, Display, Add, Sub, Mul, Div, Rem, Neg, BitAnd, BitOr, BitXor, BitNot, Shl, Shr.
fn equals(o: int8): bool
fn compare(o: int8): ?Ordering
fn totalCompare(o: int8): Ordering
fn hash<H :: [Hasher]>(&h: H): void
fn show(): string
fn showTo(out: StringBuilder): void
fn add(rhs: int8): int8
fn sub(rhs: int8): int8
fn mul(rhs: int8): int8
fn div(rhs: int8): int8
fn rem(rhs: int8): int8
fn neg(): int8
fn bitAnd(rhs: int8): int8
fn bitOr(rhs: int8): int8
fn bitXor(rhs: int8): int8
fn bitNot(): int8
fn shl(rhs: int): int8
fn shr(rhs: int): int8
extend int16 :: [
Equatable,
Ordered,
TotalOrder,
Hashable,
Display,
Add,
Sub,
Mul,
Div,
Rem,
Neg,
BitAnd,
BitOr,
BitXor,
BitNot,
Shl,
Shr
]
Conforms to Equatable, Ordered, TotalOrder, Hashable, Display, Add, Sub, Mul, Div, Rem, Neg, BitAnd, BitOr, BitXor, BitNot, Shl, Shr.
fn equals(o: int16): bool
fn compare(o: int16): ?Ordering
fn totalCompare(o: int16): Ordering
fn hash<H :: [Hasher]>(&h: H): void
fn show(): string
fn showTo(out: StringBuilder): void
fn add(rhs: int16): int16
fn sub(rhs: int16): int16
fn mul(rhs: int16): int16
fn div(rhs: int16): int16
fn rem(rhs: int16): int16
fn neg(): int16
fn bitAnd(rhs: int16): int16
fn bitOr(rhs: int16): int16
fn bitXor(rhs: int16): int16
fn bitNot(): int16
fn shl(rhs: int): int16
fn shr(rhs: int): int16
extend int32 :: [
Equatable,
Ordered,
TotalOrder,
Hashable,
Display,
Add,
Sub,
Mul,
Div,
Rem,
Neg,
BitAnd,
BitOr,
BitXor,
BitNot,
Shl,
Shr
]
Conforms to Equatable, Ordered, TotalOrder, Hashable, Display, Add, Sub, Mul, Div, Rem, Neg, BitAnd, BitOr, BitXor, BitNot, Shl, Shr.
fn equals(o: int32): bool
fn compare(o: int32): ?Ordering
fn totalCompare(o: int32): Ordering
fn hash<H :: [Hasher]>(&h: H): void
fn show(): string
fn showTo(out: StringBuilder): void
fn add(rhs: int32): int32
fn sub(rhs: int32): int32
fn mul(rhs: int32): int32
fn div(rhs: int32): int32
fn rem(rhs: int32): int32
fn neg(): int32
fn bitAnd(rhs: int32): int32
fn bitOr(rhs: int32): int32
fn bitXor(rhs: int32): int32
fn bitNot(): int32
fn shl(rhs: int): int32
fn shr(rhs: int): int32
extend uint :: [
Equatable,
Ordered,
TotalOrder,
Hashable,
Display,
Add,
Sub,
Mul,
Div,
Rem,
BitAnd,
BitOr,
BitXor,
BitNot,
Shl,
Shr
]
Conforms to Equatable, Ordered, TotalOrder, Hashable, Display, Add, Sub, Mul, Div, Rem, BitAnd, BitOr, BitXor, BitNot, Shl, Shr.
fn equals(o: uint): bool
fn compare(o: uint): ?Ordering
fn totalCompare(o: uint): Ordering
fn hash<H :: [Hasher]>(&h: H): void
fn show(): string
fn showTo(out: StringBuilder): void
fn add(rhs: uint): uint
fn sub(rhs: uint): uint
fn mul(rhs: uint): uint
fn div(rhs: uint): uint
fn rem(rhs: uint): uint
fn bitAnd(rhs: uint): uint
fn bitOr(rhs: uint): uint
fn bitXor(rhs: uint): uint
fn bitNot(): uint
fn shl(rhs: int): uint
fn shr(rhs: int): uint
extend uint8 :: [
Equatable,
Ordered,
TotalOrder,
Hashable,
Display,
Add,
Sub,
Mul,
Div,
Rem,
BitAnd,
BitOr,
BitXor,
BitNot,
Shl,
Shr
]
Conforms to Equatable, Ordered, TotalOrder, Hashable, Display, Add, Sub, Mul, Div, Rem, BitAnd, BitOr, BitXor, BitNot, Shl, Shr.
fn equals(o: uint8): bool
fn compare(o: uint8): ?Ordering
fn totalCompare(o: uint8): Ordering
fn hash<H :: [Hasher]>(&h: H): void
fn show(): string
fn showTo(out: StringBuilder): void
fn add(rhs: uint8): uint8
fn sub(rhs: uint8): uint8
fn mul(rhs: uint8): uint8
fn div(rhs: uint8): uint8
fn rem(rhs: uint8): uint8
fn bitAnd(rhs: uint8): uint8
fn bitOr(rhs: uint8): uint8
fn bitXor(rhs: uint8): uint8
fn bitNot(): uint8
fn shl(rhs: int): uint8
fn shr(rhs: int): uint8
extend uint16 :: [
Equatable,
Ordered,
TotalOrder,
Hashable,
Display,
Add,
Sub,
Mul,
Div,
Rem,
BitAnd,
BitOr,
BitXor,
BitNot,
Shl,
Shr
]
Conforms to Equatable, Ordered, TotalOrder, Hashable, Display, Add, Sub, Mul, Div, Rem, BitAnd, BitOr, BitXor, BitNot, Shl, Shr.
fn equals(o: uint16): bool
fn compare(o: uint16): ?Ordering
fn totalCompare(o: uint16): Ordering
fn hash<H :: [Hasher]>(&h: H): void
fn show(): string
fn showTo(out: StringBuilder): void
fn add(rhs: uint16): uint16
fn sub(rhs: uint16): uint16
fn mul(rhs: uint16): uint16
fn div(rhs: uint16): uint16
fn rem(rhs: uint16): uint16
fn bitAnd(rhs: uint16): uint16
fn bitOr(rhs: uint16): uint16
fn bitXor(rhs: uint16): uint16
fn bitNot(): uint16
fn shl(rhs: int): uint16
fn shr(rhs: int): uint16
extend uint32 :: [
Equatable,
Ordered,
TotalOrder,
Hashable,
Display,
Add,
Sub,
Mul,
Div,
Rem,
BitAnd,
BitOr,
BitXor,
BitNot,
Shl,
Shr
]
Conforms to Equatable, Ordered, TotalOrder, Hashable, Display, Add, Sub, Mul, Div, Rem, BitAnd, BitOr, BitXor, BitNot, Shl, Shr.
fn equals(o: uint32): bool
fn compare(o: uint32): ?Ordering
fn totalCompare(o: uint32): Ordering
fn hash<H :: [Hasher]>(&h: H): void
fn show(): string
fn showTo(out: StringBuilder): void
fn add(rhs: uint32): uint32
fn sub(rhs: uint32): uint32
fn mul(rhs: uint32): uint32
fn div(rhs: uint32): uint32
fn rem(rhs: uint32): uint32
fn bitAnd(rhs: uint32): uint32
fn bitOr(rhs: uint32): uint32
fn bitXor(rhs: uint32): uint32
fn bitNot(): uint32
fn shl(rhs: int): uint32
fn shr(rhs: int): uint32
extend float :: [Equatable, Ordered, Display, Add, Sub, Mul, Div, Rem, Neg]
Conforms to Equatable, Ordered, Display, Add, Sub, Mul, Div, Rem, Neg.
fn equals(o: float): bool
fn compare(o: float): ?Ordering
fn show(): string
fn showTo(out: StringBuilder): void
fn add(rhs: float): float
fn sub(rhs: float): float
fn mul(rhs: float): float
fn div(rhs: float): float
fn rem(rhs: float): float
fn neg(): float
extend float32 :: [Equatable, Ordered, Display, Add, Sub, Mul, Div, Rem, Neg]
Conforms to Equatable, Ordered, Display, Add, Sub, Mul, Div, Rem, Neg.
fn equals(o: float32): bool
fn compare(o: float32): ?Ordering
fn show(): string
fn showTo(out: StringBuilder): void
fn add(rhs: float32): float32
fn sub(rhs: float32): float32
fn mul(rhs: float32): float32
fn div(rhs: float32): float32
fn rem(rhs: float32): float32
fn neg(): float32
extend bool :: [Equatable, Hashable, Display]
Conforms to Equatable, Hashable, Display.
fn equals(o: bool): bool
fn hash<H :: [Hasher]>(&h: H): void
fn show(): string
fn showTo(out: StringBuilder): void
extend char :: [Equatable, Ordered, TotalOrder, Hashable, Display]
Conforms to Equatable, Ordered, TotalOrder, Hashable, Display.
fn equals(o: char): bool
fn compare(o: char): ?Ordering
fn totalCompare(o: char): Ordering
fn hash<H :: [Hasher]>(&h: H): void
fn show(): string
fn showTo(out: StringBuilder): void
extend string :: [Equatable, Display, Add]
Conforms to Equatable, Display, Add.
fn equals(o: string): bool
fn show(): string
fn showTo(out: StringBuilder): void
fn add(rhs: string): string
extend<T, U :: [From<T>]> T :: [Into<U>]
Conforms to Into<U>.
fn into(): U
extend int :: [Debug, Clone, Default]
Conforms to Debug, Clone, Default.
fn debug(): string
fn clone(): int
static fn default(): int
extend int8 :: [Debug, Clone, Default]
Conforms to Debug, Clone, Default.
fn debug(): string
fn clone(): int8
static fn default(): int8
extend int16 :: [Debug, Clone, Default]
Conforms to Debug, Clone, Default.
fn debug(): string
fn clone(): int16
static fn default(): int16
extend int32 :: [Debug, Clone, Default]
Conforms to Debug, Clone, Default.
fn debug(): string
fn clone(): int32
static fn default(): int32
extend uint :: [Debug, Clone, Default]
Conforms to Debug, Clone, Default.
fn debug(): string
fn clone(): uint
static fn default(): uint
extend uint8 :: [Debug, Clone, Default]
Conforms to Debug, Clone, Default.
fn debug(): string
fn clone(): uint8
static fn default(): uint8
extend uint16 :: [Debug, Clone, Default]
Conforms to Debug, Clone, Default.
fn debug(): string
fn clone(): uint16
static fn default(): uint16
extend uint32 :: [Debug, Clone, Default]
Conforms to Debug, Clone, Default.
fn debug(): string
fn clone(): uint32
static fn default(): uint32
extend float :: [Debug, Clone, Default]
Conforms to Debug, Clone, Default.
fn debug(): string
fn clone(): float
static fn default(): float
extend float32 :: [Debug, Clone, Default]
Conforms to Debug, Clone, Default.
fn debug(): string
fn clone(): float32
static fn default(): float32
extend bool :: [Debug, Clone, Default]
Conforms to Debug, Clone, Default.
fn debug(): string
fn clone(): bool
static fn default(): bool
extend char :: [Debug, Clone]
Conforms to Debug, Clone.
fn debug(): string
Returns the character between ', escaped as a text's characters are: '\'', '\n',
'\u{200b}'.
fn clone(): char
extend char
pub static fn fromUint32(n: uint32): ?char
Returns the character of a scalar value; null for a surrogate, 0xD800…0xDFFF, or beyond
0x10FFFF.
extend char
pub fn category(): UnicodeCategory
Returns the character's general category.
pub fn isAlpha(): bool
Returns whether this is a letter of any script: the categories Lu, Ll, Lt, Lm and Lo.
pub fn isDigit(): bool
Returns whether this is a decimal digit of any script: the category Nd.
'٣' is one. isAsciiDigit asks for 0–9 alone, and parse reads those alone.
pub fn isAlphanumeric(): bool
Returns whether this is a letter or a decimal digit: isAlpha or isDigit.
pub fn isWhitespace(): bool
Returns whether this has the property White_Space.
The space, the tab, the line ends, the no-break spaces, the ideographic space and their kin.
pub fn isUpper(): bool
Returns whether this is an uppercase letter: the category Lu.
pub fn isLower(): bool
Returns whether this is a lowercase letter: the category Ll.
pub fn isControl(): bool
Returns whether this is a control character: the category Cc.
pub fn isAsciiDigit(): bool
Returns whether this is 0–9.
pub fn isAsciiAlpha(): bool
Returns whether this is one of a–z and A–Z.
pub fn isAsciiHexDigit(): bool
Returns whether this is one of 0–9, a–f and A–F.
pub fn isAsciiWhitespace(): bool
Returns whether this is ASCII whitespace as WHATWG counts it.
The space, tab, line feed, form feed and carriage return; not the vertical tab.
pub static fn fromDigit(n: int, radix: int): ?char
Returns the character of the digit n in base radix, or null where n is no digit
of the base.
Letters are lowercase: fromDigit(11, 16) is b.
Panics
When radix is outside 2–36.
extend string :: [Hashable]
Conforms to Hashable.
fn hash<H :: [Hasher]>(&h: H): void
extend string :: [Debug, Clone, Default]
Conforms to Debug, Clone, Default.
fn debug(): string
Returns the text between ", escaped as it would be written.
["a\"b", "c"] prints as it is written, and the quotes keep the boundaries between the
elements visible.
fn debugTo(out: StringBuilder): void
fn clone(): string
static fn default(): string
extend string
pub static fn fromChars<I :: [Iterator<Item = char>]>(chars: I): string throws I.Error
Creates the text of the characters, in order.
Errors
What the iterator throws.
extend int :: [Num, Signed, Integer]
Conforms to Num, Signed, Integer.
static fn parse(s: StringView): int throws ParseError
Parses the decimal integer a text names.
Errors
A ParseError when the text is empty, not of the form, or beyond the type's range.
static fn parse(s: StringView, radix: int): int throws ParseError
Parses the integer a text names in base radix.
Panics
When radix is outside 2…36.
Errors
A ParseError when the text is empty, not of the form, or beyond the type's range.
static fn exact<T :: [Integer]>(v: T): ?int
Returns v as an int where it fits, null where it does not.
static fn clamping<T :: [Integer]>(v: T): int
Returns v as an int, held at min or max where it does not fit.
extend int8 :: [Num, Signed, Integer]
Conforms to Num, Signed, Integer.
static fn parse(s: StringView): int8 throws ParseError
Parses the decimal integer a text names.
Errors
A ParseError when the text is empty, not of the form, or beyond the type's range.
static fn parse(s: StringView, radix: int): int8 throws ParseError
Parses the integer a text names in base radix.
Panics
When radix is outside 2…36.
Errors
A ParseError when the text is empty, not of the form, or beyond the type's range.
static fn exact<T :: [Integer]>(v: T): ?int8
Returns v as an int8 where it fits, null where it does not.
static fn clamping<T :: [Integer]>(v: T): int8
Returns v as an int8, held at min or max where it does not fit.
extend int16 :: [Num, Signed, Integer]
Conforms to Num, Signed, Integer.
static fn parse(s: StringView): int16 throws ParseError
Parses the decimal integer a text names.
Errors
A ParseError when the text is empty, not of the form, or beyond the type's range.
static fn parse(s: StringView, radix: int): int16 throws ParseError
Parses the integer a text names in base radix.
Panics
When radix is outside 2…36.
Errors
A ParseError when the text is empty, not of the form, or beyond the type's range.
static fn exact<T :: [Integer]>(v: T): ?int16
Returns v as an int16 where it fits, null where it does not.
static fn clamping<T :: [Integer]>(v: T): int16
Returns v as an int16, held at min or max where it does not fit.
extend int32 :: [Num, Signed, Integer]
Conforms to Num, Signed, Integer.
static fn parse(s: StringView): int32 throws ParseError
Parses the decimal integer a text names.
Errors
A ParseError when the text is empty, not of the form, or beyond the type's range.
static fn parse(s: StringView, radix: int): int32 throws ParseError
Parses the integer a text names in base radix.
Panics
When radix is outside 2…36.
Errors
A ParseError when the text is empty, not of the form, or beyond the type's range.
static fn exact<T :: [Integer]>(v: T): ?int32
Returns v as an int32 where it fits, null where it does not.
static fn clamping<T :: [Integer]>(v: T): int32
Returns v as an int32, held at min or max where it does not fit.
extend uint :: [Num, Integer]
Conforms to Num, Integer.
static fn parse(s: StringView): uint throws ParseError
Parses the decimal integer a text names.
Errors
A ParseError when the text is empty, not of the form, or beyond the type's range.
static fn parse(s: StringView, radix: int): uint throws ParseError
Parses the integer a text names in base radix.
Panics
When radix is outside 2…36.
Errors
A ParseError when the text is empty, not of the form, or beyond the type's range.
static fn exact<T :: [Integer]>(v: T): ?uint
Returns v as an uint where it fits, null where it does not.
static fn clamping<T :: [Integer]>(v: T): uint
Returns v as an uint, held at min or max where it does not fit.
extend uint8 :: [Num, Integer]
Conforms to Num, Integer.
static fn parse(s: StringView): uint8 throws ParseError
Parses the decimal integer a text names.
Errors
A ParseError when the text is empty, not of the form, or beyond the type's range.
static fn parse(s: StringView, radix: int): uint8 throws ParseError
Parses the integer a text names in base radix.
Panics
When radix is outside 2…36.
Errors
A ParseError when the text is empty, not of the form, or beyond the type's range.
static fn exact<T :: [Integer]>(v: T): ?uint8
Returns v as an uint8 where it fits, null where it does not.
static fn clamping<T :: [Integer]>(v: T): uint8
Returns v as an uint8, held at min or max where it does not fit.
extend uint16 :: [Num, Integer]
Conforms to Num, Integer.
static fn parse(s: StringView): uint16 throws ParseError
Parses the decimal integer a text names.
Errors
A ParseError when the text is empty, not of the form, or beyond the type's range.
static fn parse(s: StringView, radix: int): uint16 throws ParseError
Parses the integer a text names in base radix.
Panics
When radix is outside 2…36.
Errors
A ParseError when the text is empty, not of the form, or beyond the type's range.
static fn exact<T :: [Integer]>(v: T): ?uint16
Returns v as an uint16 where it fits, null where it does not.
static fn clamping<T :: [Integer]>(v: T): uint16
Returns v as an uint16, held at min or max where it does not fit.
extend uint32 :: [Num, Integer]
Conforms to Num, Integer.
static fn parse(s: StringView): uint32 throws ParseError
Parses the decimal integer a text names.
Errors
A ParseError when the text is empty, not of the form, or beyond the type's range.
static fn parse(s: StringView, radix: int): uint32 throws ParseError
Parses the integer a text names in base radix.
Panics
When radix is outside 2…36.
Errors
A ParseError when the text is empty, not of the form, or beyond the type's range.
static fn exact<T :: [Integer]>(v: T): ?uint32
Returns v as an uint32 where it fits, null where it does not.
static fn clamping<T :: [Integer]>(v: T): uint32
Returns v as an uint32, held at min or max where it does not fit.
extend float :: [Num, Signed, Float]
Conforms to Num, Signed, Float.
static fn fromBits(b: uint64): float
static fn parse(s: StringView): float throws ParseError
Parses the float a text names, rounded to the nearest one.
Errors
A ParseError when the text is empty or not of a float's form.
extend float32 :: [Num, Signed, Float]
Conforms to Num, Signed, Float.
static fn fromBits(b: uint64): float32
static fn parse(s: StringView): float32 throws ParseError
Parses the float a text names, rounded to the nearest one.
Errors
A ParseError when the text is empty or not of a float's form.
extend bool :: [Parse]
Conforms to Parse.
static fn parse(s: StringView): bool throws ParseError
Parses true or false, exactly.
Errors
A ParseError for any other text.
extend string :: [Ordered, TotalOrder]
Conforms to Ordered, TotalOrder.
fn compare(o: string): ?Ordering
Compares byte by byte, which is the order of the code points.
fn totalCompare(o: string): Ordering
extend string
pub fn length(): int
Returns the length in bytes, O(1); charCount() counts the characters.
pub fn isEmpty(): bool
Returns whether it has no byte.
extend StringView :: [Pattern]
Conforms to Pattern.
fn matchAt(text: StringView, at: int): ?int
fn matchBefore(text: StringView, end: int): ?int
fn nextIn(text: StringView, from: int): ?int
extend string :: [Pattern]
Conforms to Pattern.
fn matchAt(text: StringView, at: int): ?int
fn matchBefore(text: StringView, end: int): ?int
fn nextIn(text: StringView, from: int): ?int
extend fn(char) -> bool :: [Pattern]
Conforms to Pattern.
fn matchAt(text: StringView, at: int): ?int
fn matchBefore(text: StringView, end: int): ?int
extend char :: [Pattern]
Conforms to Pattern.
fn matchAt(text: StringView, at: int): ?int
fn matchBefore(text: StringView, end: int): ?int
extend StringView
pub fn chars(): CharsIter
Returns an iterator over the characters, decoded from the bytes, from either end.
pub fn charIndices(): CharIndicesIter
Returns an iterator over the characters, each with the byte index it begins at.
pub fn charCount(): int
Returns how many characters it holds, O(n).
pub fn bytes(): uint8[]
Returns a copy of its bytes.
A copy, since a text may not change through a Slice<uint8>.
extend StringView
pub fn isEmpty(): bool
Returns whether it holds no byte.
pub fn toString(): string
Returns its bytes in a string of their own.
extend StringView :: [Equatable, Hashable, Ordered, TotalOrder, Display, Debug, Index<int>]
Conforms to Equatable, Hashable, Ordered, TotalOrder, Display, Debug, Index<int>.
fn equals(o: StringView): bool
fn hash<H :: [Hasher]>(&h: H): void
fn compare(o: StringView): ?Ordering
fn totalCompare(o: StringView): Ordering
fn show(): string
fn showTo(out: StringBuilder): void
fn debug(): string
fn index(k: int): char
extend string :: [Index<int>]
Conforms to Index<int>.
fn index(k: int): char
extend string
pub static fn fromUtf8(bytes: Slice<uint8>): string throws Utf8Error
Creates the text the bytes are, copied.
Errors
A Utf8Error where the bytes are no well-formed UTF-8.
pub static fn fromUtf8Lossy(bytes: Slice<uint8>): string
Creates the text the bytes are, each maximal ill-formed part replaced by U+FFFD.
This is the Unicode Standard's recommended practice (3.9) and WHATWG's decoding.
extend int :: [Format]
Conforms to Format.
fn format(spec: StringView, out: StringBuilder): void
extend int8 :: [Format]
Conforms to Format.
fn format(spec: StringView, out: StringBuilder): void
extend int16 :: [Format]
Conforms to Format.
fn format(spec: StringView, out: StringBuilder): void
extend int32 :: [Format]
Conforms to Format.
fn format(spec: StringView, out: StringBuilder): void
extend uint :: [Format]
Conforms to Format.
fn format(spec: StringView, out: StringBuilder): void
extend uint8 :: [Format]
Conforms to Format.
fn format(spec: StringView, out: StringBuilder): void
extend uint16 :: [Format]
Conforms to Format.
fn format(spec: StringView, out: StringBuilder): void
extend uint32 :: [Format]
Conforms to Format.
fn format(spec: StringView, out: StringBuilder): void
extend float :: [Format]
Conforms to Format.
fn format(spec: StringView, out: StringBuilder): void
extend float32 :: [Format]
Conforms to Format.
fn format(spec: StringView, out: StringBuilder): void
extend string :: [Format]
Conforms to Format.
fn format(spec: StringView, out: StringBuilder): void
extend char :: [Format]
Conforms to Format.
fn format(spec: StringView, out: StringBuilder): void
extend bool :: [Format]
Conforms to Format.
fn format(spec: StringView, out: StringBuilder): void
extend<I :: [Iterator]> I :: [Iterable<Iter = I>]
Conforms to Iterable<Iter = I>.
fn iter(): I
extend int :: [Step]
Conforms to Step.
static fn first(): int
static fn last(): int
fn after(): int
fn before(): int
extend int8 :: [Step]
Conforms to Step.
static fn first(): int8
static fn last(): int8
fn after(): int8
fn before(): int8
extend int16 :: [Step]
Conforms to Step.
static fn first(): int16
static fn last(): int16
fn after(): int16
fn before(): int16
extend int32 :: [Step]
Conforms to Step.
static fn first(): int32
static fn last(): int32
fn after(): int32
fn before(): int32
extend uint :: [Step]
Conforms to Step.
static fn first(): uint
static fn last(): uint
fn after(): uint
fn before(): uint
extend uint8 :: [Step]
Conforms to Step.
static fn first(): uint8
static fn last(): uint8
fn after(): uint8
fn before(): uint8
extend uint16 :: [Step]
Conforms to Step.
static fn first(): uint16
static fn last(): uint16
fn after(): uint16
fn before(): uint16
extend uint32 :: [Step]
Conforms to Step.
static fn first(): uint32
static fn last(): uint32
fn after(): uint32
fn before(): uint32
extend char :: [Step]
Conforms to Step.
static fn first(): char
static fn last(): char
fn after(): char
fn before(): char
extend<T> T[] :: [Iterable]
Conforms to Iterable.
fn iter(): SliceIter<T>
extend<T> Slice<T> :: [Iterable]
Conforms to Iterable.
fn iter(): SliceIter<T>
extend<T> T[] :: [FromIterator<T>]
Conforms to FromIterator<T>.
static fn fromIter<I :: [Iterator<Item = T>]>(it: I): T[] throws I.Error
Collects the values into an array, in order, in one pass.
A buffer that doubles holds them, its first value in the slots not yet written, then one
copy of the length is made. The buffer starts at the iterator's sizeHint, and where
that was exact (an array's walk, a view's) the buffer is the array, with no copy at the
end.
Errors
What the iterator throws.
extend<T> Slice<T>
pub fn isEmpty(): bool
Returns whether there is no element.
pub fn copyInto(into: Slice<T>): void
Copies the elements into into, which is at least as long; a longer one keeps its rest.
The two may overlap either way, xs[0..4].copyInto(xs[2..6]) as well as the reverse.
Panics
When into is shorter (LYR-RT0003).
pub fn get(i: int): ?T
Returns the element at i, or null outside 0 ≤ i < length().
pub fn first(): ?T
Returns the first element, or null where there is none.
pub fn last(): ?T
Returns the last element, or null where there is none.
pub fn swap(i: int, j: int): void
Exchanges the elements at i and j.
Panics
When an index is outside the elements, as [i] does.
pub fn reverse(): void
Reverses the elements in place.
extend<T> Slice<T> :: [Add<Out = T[]>]
Conforms to Add<Out = T[]>.
fn add(rhs: Slice<T>): T[]
extend<T :: [Equatable]> Slice<T> :: [Contains<T>]
Conforms to Contains<T>.
fn contains(x: T): bool
extend<T :: [Equatable]> T[] :: [Contains<T>]
Conforms to Contains<T>.
fn contains(x: T): bool
extend StringView :: [Contains<char>]
Conforms to Contains<char>.
extend string :: [Contains<char>]
Conforms to Contains<char>.
extend<T :: [Clone]> Slice<T>
pub fn fill(v: T): void
Sets every element to a clone of v, so no object is shared into several slots.
extend<T> Slice<T>
pub fn sortBy<E :: [Error]>(cmp: fn(T, T) -> Ordering throws E): void throws E
Sorts the elements in the order cmp gives, equal ones keeping theirs.
A merge sort: runs of 16 sorted by insertion, then merged pairwise through a buffer of the length.
Errors
What cmp throws ends the sort, and the call throws it; the elements are then in some
order, every one still there.
pub fn sortByKey<K :: [TotalOrder], E :: [Error]>(key: fn(T) -> K throws E): void throws E
Sorts the elements in the order of their keys, equal keys keeping theirs.
Errors
What key throws, as for sortBy's comparison.
extend<T :: [TotalOrder]> Slice<T>
pub fn sort(): void
Sorts the elements in ascending order, equal ones keeping theirs.
sortBy's merge sort with totalCompare called directly.
pub fn sortUnstable(): void
Sorts the elements in ascending order, equal ones in any order.
In place, without a buffer: a quicksort, falling back to a heap sort where it would go quadratic.
extend<T :: [Equatable]> T[] :: [Equatable]
Conforms to Equatable.
fn equals(o: T[]): bool
extend<T :: [Equatable]> Slice<T> :: [Equatable]
Conforms to Equatable.
fn equals(o: Slice<T>): bool
extend<T :: [Debug]> T[] :: [Debug, Display]
Conforms to Debug, Display.
fn debug(): string
fn debugTo(out: StringBuilder): void
fn show(): string
fn showTo(out: StringBuilder): void
extend<T :: [Debug]> Slice<T> :: [Debug, Display]
Conforms to Debug, Display.
fn debug(): string
fn debugTo(out: StringBuilder): void
fn show(): string
fn showTo(out: StringBuilder): void
extend<T :: [Equatable]> ?T :: [Equatable]
Conforms to Equatable.
fn equals(o: ?T): bool
extend<T :: [Hashable]> ?T :: [Hashable]
Conforms to Hashable.
fn hash<H :: [Hasher]>(&h: H): void
extend<T :: [Debug]> ?T :: [Debug]
Conforms to Debug.
fn debug(): string
extend<T :: [Clone]> T[] :: [Clone]
Conforms to Clone.
fn clone(): T[]
extend<T :: [Clone]> ?T :: [Clone]
Conforms to Clone.
fn clone(): ?T
extend<T0 :: [Clone], T1 :: [Clone]> (T0, T1) :: [Clone]
Conforms to Clone.
fn clone(): (T0, T1)
extend<T0 :: [Clone], T1 :: [Clone], T2 :: [Clone]> (T0, T1, T2) :: [Clone]
Conforms to Clone.
fn clone(): (T0, T1, T2)
extend<T0 :: [Equatable], T1 :: [Equatable]> (T0, T1) :: [Equatable]
Conforms to Equatable.
fn equals(o: (T0, T1)): bool
extend<T0 :: [Hashable], T1 :: [Hashable]> (T0, T1) :: [Hashable]
Conforms to Hashable.
fn hash<H :: [Hasher]>(&h: H): void
extend<T0 :: [Debug], T1 :: [Debug]> (T0, T1) :: [Debug]
Conforms to Debug.
fn debug(): string
fn debugTo(out: StringBuilder): void
extend<T0 :: [Display], T1 :: [Display]> (T0, T1) :: [Display]
Conforms to Display.
fn show(): string
fn showTo(out: StringBuilder): void
extend<T0 :: [Equatable], T1 :: [Equatable], T2 :: [Equatable]> (T0, T1, T2) :: [Equatable]
Conforms to Equatable.
fn equals(o: (T0, T1, T2)): bool
extend<T0 :: [Hashable], T1 :: [Hashable], T2 :: [Hashable]> (T0, T1, T2) :: [Hashable]
Conforms to Hashable.
fn hash<H :: [Hasher]>(&h: H): void
extend<T0 :: [Debug], T1 :: [Debug], T2 :: [Debug]> (T0, T1, T2) :: [Debug]
Conforms to Debug.
fn debug(): string
fn debugTo(out: StringBuilder): void
extend<T0 :: [Display], T1 :: [Display], T2 :: [Display]> (T0, T1, T2) :: [Display]
Conforms to Display.
fn show(): string
fn showTo(out: StringBuilder): void
extend<T0 :: [Equatable], T1 :: [Equatable], T2 :: [Equatable], T3 :: [Equatable]> (T0, T1, T2, T3) :: [
Equatable
]
Conforms to Equatable.
fn equals(o: (T0, T1, T2, T3)): bool
extend<T0 :: [Hashable], T1 :: [Hashable], T2 :: [Hashable], T3 :: [Hashable]> (T0, T1, T2, T3) :: [
Hashable
]
Conforms to Hashable.
fn hash<H :: [Hasher]>(&h: H): void
extend<T0 :: [Debug], T1 :: [Debug], T2 :: [Debug], T3 :: [Debug]> (T0, T1, T2, T3) :: [Debug]
Conforms to Debug.
fn debug(): string
fn debugTo(out: StringBuilder): void
extend<T0 :: [Display], T1 :: [Display], T2 :: [Display], T3 :: [Display]> (T0, T1, T2, T3) :: [
Display
]
Conforms to Display.
fn show(): string
fn showTo(out: StringBuilder): void
extend<T0 :: [Equatable], T1 :: [Equatable], T2 :: [Equatable], T3 :: [Equatable], T4 :: [Equatable]> (T0, T1, T2, T3, T4) :: [
Equatable
]
Conforms to Equatable.
fn equals(o: (T0, T1, T2, T3, T4)): bool
extend<T0 :: [Hashable], T1 :: [Hashable], T2 :: [Hashable], T3 :: [Hashable], T4 :: [Hashable]> (T0, T1, T2, T3, T4) :: [
Hashable
]
Conforms to Hashable.
fn hash<H :: [Hasher]>(&h: H): void
extend<T0 :: [Debug], T1 :: [Debug], T2 :: [Debug], T3 :: [Debug], T4 :: [Debug]> (T0, T1, T2, T3, T4) :: [
Debug
]
Conforms to Debug.
fn debug(): string
fn debugTo(out: StringBuilder): void
extend<T0 :: [Display], T1 :: [Display], T2 :: [Display], T3 :: [Display], T4 :: [Display]> (T0, T1, T2, T3, T4) :: [
Display
]
Conforms to Display.
fn show(): string
fn showTo(out: StringBuilder): void
extend<T0 :: [Equatable], T1 :: [Equatable], T2 :: [Equatable], T3 :: [Equatable], T4 :: [Equatable], T5 :: [Equatable]> (T0, T1, T2, T3, T4, T5) :: [
Equatable
]
Conforms to Equatable.
fn equals(o: (T0, T1, T2, T3, T4, T5)): bool
extend<T0 :: [Hashable], T1 :: [Hashable], T2 :: [Hashable], T3 :: [Hashable], T4 :: [Hashable], T5 :: [Hashable]> (T0, T1, T2, T3, T4, T5) :: [
Hashable
]
Conforms to Hashable.
fn hash<H :: [Hasher]>(&h: H): void
extend<T0 :: [Debug], T1 :: [Debug], T2 :: [Debug], T3 :: [Debug], T4 :: [Debug], T5 :: [Debug]> (T0, T1, T2, T3, T4, T5) :: [
Debug
]
Conforms to Debug.
fn debug(): string
fn debugTo(out: StringBuilder): void
extend<T0 :: [Display], T1 :: [Display], T2 :: [Display], T3 :: [Display], T4 :: [Display], T5 :: [Display]> (T0, T1, T2, T3, T4, T5) :: [
Display
]
Conforms to Display.
fn show(): string
fn showTo(out: StringBuilder): void
extend<T0 :: [Equatable], T1 :: [Equatable], T2 :: [Equatable], T3 :: [Equatable], T4 :: [Equatable], T5 :: [Equatable], T6 :: [Equatable]> (T0, T1, T2, T3, T4, T5, T6) :: [
Equatable
]
Conforms to Equatable.
fn equals(o: (T0, T1, T2, T3, T4, T5, T6)): bool
extend<T0 :: [Hashable], T1 :: [Hashable], T2 :: [Hashable], T3 :: [Hashable], T4 :: [Hashable], T5 :: [Hashable], T6 :: [Hashable]> (T0, T1, T2, T3, T4, T5, T6) :: [
Hashable
]
Conforms to Hashable.
fn hash<H :: [Hasher]>(&h: H): void
extend<T0 :: [Debug], T1 :: [Debug], T2 :: [Debug], T3 :: [Debug], T4 :: [Debug], T5 :: [Debug], T6 :: [Debug]> (T0, T1, T2, T3, T4, T5, T6) :: [
Debug
]
Conforms to Debug.
fn debug(): string
fn debugTo(out: StringBuilder): void
extend<T0 :: [Display], T1 :: [Display], T2 :: [Display], T3 :: [Display], T4 :: [Display], T5 :: [Display], T6 :: [Display]> (T0, T1, T2, T3, T4, T5, T6) :: [
Display
]
Conforms to Display.
fn show(): string
fn showTo(out: StringBuilder): void
extend<T0 :: [Equatable], T1 :: [Equatable], T2 :: [Equatable], T3 :: [Equatable], T4 :: [Equatable], T5 :: [Equatable], T6 :: [Equatable], T7 :: [Equatable]> (T0, T1, T2, T3, T4, T5, T6, T7) :: [
Equatable
]
Conforms to Equatable.
fn equals(o: (T0, T1, T2, T3, T4, T5, T6, T7)): bool
extend<T0 :: [Hashable], T1 :: [Hashable], T2 :: [Hashable], T3 :: [Hashable], T4 :: [Hashable], T5 :: [Hashable], T6 :: [Hashable], T7 :: [Hashable]> (T0, T1, T2, T3, T4, T5, T6, T7) :: [
Hashable
]
Conforms to Hashable.
fn hash<H :: [Hasher]>(&h: H): void
extend<T0 :: [Debug], T1 :: [Debug], T2 :: [Debug], T3 :: [Debug], T4 :: [Debug], T5 :: [Debug], T6 :: [Debug], T7 :: [Debug]> (T0, T1, T2, T3, T4, T5, T6, T7) :: [
Debug
]
Conforms to Debug.
fn debug(): string
fn debugTo(out: StringBuilder): void
extend<T0 :: [Display], T1 :: [Display], T2 :: [Display], T3 :: [Display], T4 :: [Display], T5 :: [Display], T6 :: [Display], T7 :: [Display]> (T0, T1, T2, T3, T4, T5, T6, T7) :: [
Display
]
Conforms to Display.
fn show(): string
fn showTo(out: StringBuilder): void
extend<Y, R> Coroutine<Y, R> :: [Identity]
Conforms to Identity.
fn equals(o: Coroutine<Y, R>): bool
fn hash<H :: [Hasher]>(&h: H): void