Library

std/core

Auto-imported in every Vader program.

12 files lib/std/core/array.vader, lib/std/core/bigint.vader, lib/std/core/buffer.vader, lib/std/core/core.vader, lib/std/core/dtoa.vader, lib/std/core/dtoa_tables.vader, lib/std/core/f2s.vader, lib/std/core/integers.vader, lib/std/core/parse_float.vader, lib/std/core/parse_float_tables.vader, lib/std/core/primitives.vader, lib/std/core/utf8.vader 80 exports

Layout :

  1. Trait declarations (Display, Equals, Comparable, Hash, Clone, arithmetic, indexing, containment, iteration, error)
  2. Core type definitions and their impls (Continuation, Range) + the blanket array / Display→string impls

The primitive-type impls (Display, Equals, Hash, Comparable, Step, arithmetic, string) live in the sibling primitives.vader: same module "std/core", split out so neither file outgrows ~500 LoC.

The base Error trait marking the error side of a union lives in §1 ; the concrete error structs are user-defined.

Types

ArrayOps :: trait<T>

The built-in methods of T[]. Bodyless: provided by the compiler's array ops, not a Vader body. T is the element type.

Methods

len :: fn(self) -> i64

Number of live elements.

push :: fn(self, value: T) -> void

Append value to the end, growing the backing storage as needed.

push_all :: fn(self, other: T[]) -> void

Append every element of other (a borrowed, immutable view).

copy_to :: fn(self, src_off: i64, dst: T[], dst_off: i64, count: i64) -> void

Copy count elements from self[src_off..] into dst[dst_off..]. Reads self ; it is dst that is written.

remove_last :: fn(self) -> T | null

Remove and return the last element, or null when empty.

clear :: fn(self) -> void

Drop every element (length → 0), keeping the reserved capacity.

BigInt :: u32[]

A fixed-width natural (unsigned) big integer : little-endian base-2^32 limbs. Zero is any run of zero limbs: [] usually, [0] after a / that leaves nothing in the top limb.

BigInt :: u32[] is a distinct newtype (array-backed) : the structural array ops (index, len/push, for-in, [...] literals) forward to the backing array, while the scalar arithmetic is overloaded on the nominal type: bigint * u32 (Mul<u32>) and bigint / u32 → [quotient, remainder] (Div<u32, [BigInt, u32]>). mul_add_small (×+add) has no operator form and stays a method.

Implements Mul<u32, BigInt> mul :: fn(self, other: u32) -> BigInt
Implements Zero zero :: fn() -> BigInt
Implements Div<u32, [BigInt, u32]> div :: fn(self, d: u32) -> [BigInt, u32]
Buffer :: struct

Opaque handle to a GC-managed contiguous byte region. Carries no fields : the backing bytes live in a dedicated runtime object (the BUFFER sentinel type), addressed only through the @intrinsic methods below. Never built via a struct literal: allocate with new_byte_buffer(n).

Implements ByteAccess
Display :: trait

Convert a value to its canonical string form. Drives compile-time string interpolation ("${value}") and the print / println family in std/io. Every primitive type ships an @intrinsic impl ; user types opt in by declaring their own to_string.

Methods

to_string :: fn(self) -> string
No description.
Equals :: trait

Structural equality. Powers the == and != operators : a != b is !a.equals(b), so the two cannot disagree.

Methods

equals :: fn(self, other: Self) -> bool
No description.
Comparable :: trait

Total ordering. Powers < / <= / > / >= : a < b is a.compare(b) < 0, so an impl provides compare alone and the four operators cannot disagree with it.

compare(a, b) must return:

  • < 0 when a is strictly less than b,
  • = 0 when they're equal,
  • > 0 when a is strictly greater than b.

Methods

compare :: fn(self, other: Self) -> i32
No description.
Hash :: trait

Hash codes for MutableMap / MutableSet keys: equal values (Equals), equal hashes. A map's first probe reads the LOW bits; a key varying only in high ones should mix them down.

Methods

hash :: fn(self) -> u64
No description.
Step :: trait

Advance one position along a discrete sequence. Sole obligation : step() returns the next value after self. Used by Range[T : Step & Comparable] implements Iterator<T> so a single generic impl covers every integer width plus char: concrete + 1 / codepoint-bump logic lives in each primitive's Step impl instead of being repeated per Range<T> impl.

Methods

step :: fn(self) -> Self
No description.
Clone :: trait

Explicit deep copy. clone(x) (free function) dispatches into this when T: Clone ; primitive types don't need it (value-typed by default).

Methods

clone :: fn(self) -> Self
No description.
Into :: trait<Target>

Type-to-type conversion. Two surfaces :

  • Implicit : when a value of type S flows into a slot expecting Target and S implements Into<Target>, the compiler inserts value.into() at the boundary. Sites : call args with a typed parameter, return values, x: T = v, struct-literal fields, and the receiver of a method call no function takes as is.
  • Explicit : Target(value), the same Type(value) syntax that performs primitive numeric casts (u32(x), i64(x)). When Target is a user type, the compiler routes the call through the matching Into impl instead of emitting a primitive cast.

Coercion is not transitive (A → B → C never auto-chains), and T implements Into<T> is forbidden. SPEC §4 Type coercion via Into gives the full rules, among them which targets convert.

Methods

into :: fn(self) -> Target
No description.
Add :: trait<Rhs = Self, Out = Self>

+ dispatch. Numeric primitives use the built-in bytecode op directly ; user types implement Add to opt into the operator form. Rhs is the right-operand type and Out the result: both default to Self, so the common homogeneous case is just implements Add; heterogeneous operators (e.g. Instant implements Add<Duration, Instant>) spell the params.

Methods

add :: fn(self, other: Rhs) -> Out
No description.
Sub :: trait<Rhs = Self, Out = Self>

- dispatch. See Add.

Methods

sub :: fn(self, other: Rhs) -> Out
No description.
Mul :: trait<Rhs = Self, Out = Self>

* dispatch. See Add.

Methods

mul :: fn(self, other: Rhs) -> Out
No description.
Div :: trait<Rhs = Self, Out = Self>

/ dispatch. See Add.

Methods

div :: fn(self, other: Rhs) -> Out
No description.
Rem :: trait<Rhs = Self, Out = Self>

% dispatch. See Add.

Methods

rem :: fn(self, other: Rhs) -> Out
No description.
Zero :: trait

The additive identity of a type: what a sum of no elements is. A static member : called on the type, T.zero() in a body bounded by T: Zero.

Methods

zero :: fn() -> Self

The value z for which z + x == x.

One :: trait

The multiplicative identity of a type: what a product of no elements is. A static member, like Zero.zero.

Methods

one :: fn() -> Self

The value u for which u * x == x.

FloatBits :: trait

Bit-level view of a float as its raw IEEE 754 integer pattern. This is NOT a numeric conversion : u64(x) truncates the VALUE (3.7 → 3), whereas x.to_bits() returns the exact bits (3.0 → 0x4008000000000000). The inverse is BitsFloat::from_bits. Powers shortest-double formatting and any float bit-fiddling, with no per-target runtime symbol (lowers to a union cast). Mirrors Rust's f64::to_bits / f64::from_bits (deliberately distinct from the as/cast conversion).

Methods

to_bits :: fn(self) -> u64

The raw IEEE 754 bit pattern of self.

BitsFloat :: trait

Inverse of FloatBits: reconstruct an f64 from a raw IEEE 754 bit pattern.

Methods

from_bits :: fn(self) -> f64

Reinterpret self's bits as an f64 (NOT f64(self), which widens the integer value).

Float32Bits :: trait

32-bit analogue of FloatBits : the raw IEEE 754 u32 bit pattern of an f32 (NOT u32(self), which truncates the value). Powers the pure-Vader shortest-f32 formatter (Ryu f2s). Inverse is Bits32Float::from_bits.

Methods

to_bits :: fn(self) -> u32

The raw IEEE 754 bit pattern of self.

Bits32Float :: trait

Inverse of Float32Bits: reconstruct an f32 from a raw IEEE 754 u32 bit pattern (NOT f32(self), which widens the integer value).

Methods

from_bits :: fn(self) -> f32

Reinterpret self's bits as an f32.

Index :: trait<I, T>

Indexed read: a[i] dispatches through this when a isn't a built-in array. I is the index type, T the element type.

Methods

at :: fn(self, i: I) -> T
No description.
IndexSet :: trait<I, T>

Indexed write: a[i] = v. Symmetric with Index.

Methods

set_at :: fn(self, i: I, v: T)
No description.
Contains :: trait<T>

Membership test. x in coll desugars to coll.contains(x) ; x !in coll desugars to !coll.contains(x). Implemented by Range (for the integer / char ranges), MutableMap, MutableSet, and any user type that wants infix in support.

Methods

contains :: fn(self, value: T) -> bool
No description.
Continuation :: enum(u8)

How one iterator step ended, see Iterator.next.

Variants

Continue

The step produced a value.

Stop

The iteration is over; the value beside this one means nothing.

Iterator :: trait<T>

Pull-based iterator. The lowerer dispatches for x in iter through the impl table: users never call next directly. What consumes one (count, last, collect, find...) is a free function over Iterator<T> in std/iter, a for over its argument.

next() hands back the element and whether the iteration goes on. A PAIR rather than a wrapper around a nullable: the pair crosses the call in registers instead of through the heap, and it makes T = U | null unremarkable: Continuation says whether there is an element, so a null ELEMENT is just an element.

The element beside Continuation.Stop is INDETERMINATE. An implementation hands over whatever T it has rather than manufacturing one, and no consumer may read it before testing the Continuation.

Methods

next :: fn(self) -> [T, Continuation]
No description.
Error :: trait

Base trait for every error type usable in T | Error returns. Any struct implementing Error participates in such error unions ; a caller narrows on it (if r is Error) and returns it to propagate.

Methods

message :: fn(self) -> string
No description.
Suspended :: struct

Sentinel returned by Async.resume when the coroutine suspended (it awaited something not yet ready) rather than completing. T | Suspended stays unambiguous because Suspended is a distinct nominal type, where Iterator.next carries the same information BESIDE the element instead, in its Continuation.

Fields

wake_at: i64 = 0

The scheduler time (sched_now, in ms) before which resuming again cannot make progress: a driver holding several awaitables re-drives this one only once the clock reaches it. 0, the default, means unknown: re-drive it on every wake. A coroutine reports the value of the child it is parked on.

Async :: trait<T>

The awaitable produced by calling an async fn: await e unwraps Async<T> to T. Each async fn's synthesised state struct implements it (wired in lowering). Carries no error semantics of its own ; a fallible async fn returns Async<T | SomeError>.

Methods

resume :: fn(self) -> T | Suspended

Drive the coroutine one step : returns the final value T on completion, or the Suspended sentinel when it awaited something not yet ready. Synthesised per async fn by lowering. The resumed value is delivered out-of-band (a synthesised erased frame slot the scheduler sets before each call), so this signature stays source-clean.

cancel :: fn(self) -> void

Tear the awaitable down without completing it : run any pending defers (LIFO), recursively cancel the child it is parked on, and retire it. Called only on a not-yet-completed awaitable (a loser of race / join_any / timeout, or a subtree whose parent was cancelled): internal to the runtime, never invoked by user code in v1.

The default is a no-op : a hand-written awaitable holding no resources needs no teardown. The compiler synthesises an override per async fn (drain its defers + recurse into its current child) ; the concurrency combinators override it to cancel every child they own.

Field :: struct

One field of a struct type as exposed by the @fields(T) reflection intrinsic. name is the source-level identifier ; type carries the field's declared type as a runtime type value.

Fields

name: string
No description.
type: type
No description.
Range :: struct<T>

Range produced by 0..<n / 0..=n and 'a'..='z'. Generic over the bound type so integer ranges (every signed / unsigned width plus i64 / i64) and char ranges share a single struct. The cursor field is advanced by each next call via implicit struct-ref mutation.

Fields

start: T
No description.
end: T
No description.
inclusive: bool
No description.
done: bool = false

Set once an inclusive range has handed out end. Its cursor stays there: a step past end may leave T (past 255 in a u8).

cursor: T
No description.
Implements Contains<T> contains :: fn(self, value: T) -> bool
Implements Iterator<T> next :: fn(self) -> [T, Continuation]
i8 :: Int in -0x80..=0x7F

A signed 8-bit integer.

i16 :: Int in -0x8000..=0x7FFF

A signed 16-bit integer.

i32 :: Int in -0x8000_0000..=0x7FFF_FFFF

A signed 32-bit integer, the type of an integer literal nothing else types.

i64 :: Int in -0x8000_0000_0000_0000..=0x7FFF_FFFF_FFFF_FFFF

A signed 64-bit integer, the type of a length, an index and a size.

u8 :: Int in 0..=0xFF

An unsigned 8-bit integer.

u16 :: Int in 0..=0xFFFF

An unsigned 16-bit integer.

u32 :: Int in 0..=0xFFFF_FFFF

An unsigned 32-bit integer.

u64 :: Int in 0..=0xFFFF_FFFF_FFFF_FFFF

An unsigned 64-bit integer.

DecimalParts :: struct

The scanned parts of a decimal float : significand w (first <= 19 significant digits), power-of-ten exponent q, sign, and whether more than 19 significant digits were seen (needs the slow path, not yet built).

Fields

w: u64
No description.
q: i32
No description.
negative: bool
No description.
too_many_digits: bool
No description.

Functions

filled :: fn<T>(n: i64, make: fn() -> T) -> T[]

Build an array of n elements, calling make once per slot.

The complement of [v] * n, which repeats ONE reference into every slot and so cannot build n distinct objects (see W0013).

Parameters

ni64 number of elements to build.
makefn() -> T called once per slot, in order ; its result fills that slot.

Returns

T[] a fresh array of length n, its capacity reserved up front.

Example

rows: BlockId[][] = filled(block_count, () -> [])   // n DISTINCT arrays
seen :: filled(n, new_visited_set)                  // or a named factory
filled_indexed :: fn<T>(n: i64, make: fn(i64) -> T) -> T[]

Build an array of n elements, calling make(i) for slot i.

The positional twin of filled : reach for it when an element depends on where it sits, and for filled when it doesn't.

Parameters

ni64 number of elements to build.
makefn(i64) -> T called once per slot, in order, with that slot's index.

Returns

T[] a fresh array of length n, its capacity reserved up front.

Example

squares :: filled_indexed(n, (i) -> i32(i * i))
rows    :: filled_indexed(n, (i) -> Row { .id = i })
content_equals :: fn<T: Equals>(self: T[], other: T[]) -> bool

Whether self and other hold equal elements in the same order : the same length, and self[i] == other[i] at every index.

Parameters

selfT[] No description.
otherT[] the array compared with.

Returns

bool

Example

assert([1, 2].content_equals([1, 2]), "same contents")
is_permutation_of :: fn<T: Equals>(self: T[], other: T[]) -> bool

Whether other holds the elements of self in some order, each as many times. Quadratic : each element of self is looked for among the elements of other not yet matched.

Parameters

selfT[] No description.
otherT[] the array compared with.

Returns

bool

Example

assert([1, 2, 2].is_permutation_of([2, 1, 2]), "same elements")
contains_all :: fn<T: Equals>(self: T[], other: T[]) -> bool

Whether every element of other is in self. Each counts once : [1].contains_all([1, 1]) holds.

Parameters

selfT[] No description.
otherT[] the elements looked for.

Returns

bool
is_disjoint :: fn<T: Equals>(self: T[], other: T[]) -> bool

Whether self and other share no element.

Parameters

selfT[] No description.
otherT[] the array compared with.

Returns

bool
mul_add_small :: fn(self: BigInt, mul: u32, add: u32) -> BigInt

Multiply by a small scalar and add a small scalar : self * mul + add.

One limb pass, O(n). The single primitive behind the ×5 power-of-five step and the ×10 + digit decimal accumulation.

Parameters

selfBigInt the operand.
mulu32 the u32 multiplier.
addu32 a u32 addend folded into the low limb (carrying up).

Returns

BigInt self * mul + add, one limb wider when it overflows.
div_small :: fn(self: BigInt, d: u32) -> BigInt

floor(self / d), discarding the remainder.

Parameters

selfBigInt No description.
du32 No description.

Returns

shl :: fn(self: BigInt, bits: i32) -> BigInt

Left-shift the whole big-int by bits (>= 0).

Parameters

selfBigInt the operand.
bitsi32 the shift amount in bits.

Returns

BigInt self << bits.

is_zero

fn 2 overloads
is_zero :: fn(self: BigInt) -> bool

True when every limb is zero. The generic is_zero does not apply : BigInt has no Equals, and its zero has several forms.

Parameters

selfBigInt No description.

Returns

bool
is_zero :: fn<T: Zero & Equals>(self: T) -> bool

Whether self is its type's zero, compared with ==.

Parameters

selfT the value to test.

Returns

bool
any_below :: fn(self: BigInt, pos: i32) -> bool

True when any set bit lies strictly below bit position pos.

Parameters

selfBigInt No description.
posi32 No description.

Returns

bool
bit_len :: fn(self: BigInt) -> i32

Bit length : position of the highest set bit + 1 (0 for zero).

Parameters

selfBigInt the operand.

Returns

i32 the number of significant bits.
bits64 :: fn(self: BigInt, off: i32) -> u64

The 64 bits starting at bit offset off, little-endian.

Parameters

selfBigInt the operand.
offi32 bit offset (>= 0) ; bits past the top read as 0.

Returns

u64 the 64-bit window (self >> off) & (2^64 - 1).
top128 :: fn(self: BigInt) -> [u64, u64]

Top 128 bits (floor), normalized so bit 127 is set.

Parameters

selfBigInt a NON-zero operand.

Returns

[u64, u64] [hi, lo]: the leading 128 bits, left-shifted so the most significant bit lands in bit 127 of hi.
two_pow :: fn(k: i32) -> BigInt

2^k as a BigInt.

Parameters

ki32 a non-negative exponent.

Returns

BigInt the power of two with bit k set and all others clear.
shl128 :: fn(hi: u64, lo: u64, s: i32) -> [u64, u64]

Left-shift a raw 128-bit value (hi:lo) by s in [0, 127].

Operates on a two-word value rather than a BigInt: a shared helper for top128 and the dtoa split rows.

Parameters

hiu64 No description.
lou64 No description.
si32 No description.

Returns

[u64, u64] the shifted [hi, lo] ; bits above 128 are dropped.
new_byte_buffer :: fn(cap: i64) -> Buffer

Allocate a Buffer of cap zeroed bytes. Lowers to the buffer.new op.

Parameters

capi64 the byte count.

Returns

array_iter :: fn<T>(arr: T[]) -> Iterator<T>

Iterate a T[]. for x in arr has its own fast path and never comes here; this is what an array COERCED to Iterator<T> becomes.

A generator rather than a hand-written impl, and that is forced rather than chosen: next must pair its element with a Continuation, and on Stop there is no T to pair: an empty array holds none, and T promises nothing that would build one. A generator's next is synthesised by the lowerer, which pairs the type's zero; a ref slot takes NULL whatever T says, and that is expressible there and not here.

Parameters

arrT[] No description.

Returns

scan_decimal :: fn(s: string) -> DecimalParts | null

Scan a decimal float string into DecimalParts, or null on malformed input (empty, no digits, a bare exponent, trailing junk). w holds the first 19 significant digits ; leading zeros are skipped and q tracks the decimal point + exponent.

Parameters

sstring the decimal float text.

Returns

DecimalParts | null the scanned parts, or null when s is not a decimal float.
eisel_lemire :: fn(w0: u64, q: i32) -> u64

Eisel-Lemire : the packed IEEE-754 MAGNITUDE bits of w * 10^q (sign not applied), correctly rounded for w with <= 19 significant digits. w == 0 yields +0 ; q below -342 yields 0, above 308 yields inf.

Parameters

w0u64 the significand (<= 19 significant digits).
qi32 the power-of-ten exponent.

Returns

u64 (power2 << 52) | mantissa, OR the caller's sign bit onto it.
parse_f64 :: fn(s: string) -> f64 | null

Parse a decimal float string to f64, or null on malformed input. Correctly rounded : the Eisel-Lemire fast path for <= 19 significant digits, an exact big-int slow path for more.

Parameters

sstring the decimal float text.

Returns

f64 | null the parsed f64, or null when s is not a decimal float.
finish_buffer :: fn(self: Buffer, len: i64) -> string

Intern the buffer's leading len bytes as a string (one atom-table copy).

Parameters

selfBuffer No description.
leni64 No description.

Returns

string
byte_len :: fn(s: string) -> i64

Byte length of s (its UTF-8 byte count), an @intrinsic read straight off the interned atom. String-only: a u8[] uses .len() directly.

Parameters

sstring No description.

Returns

i64
byte_at :: fn(s: string, i: i64) -> u8

The byte at index i of s: an @intrinsic header-free read straight off the interned atom, no read-only u8[] view materialised: how code reads a string's bytes, the peer of byte_len for the [i] case.

Parameters

sstring No description.
ii64 No description.

Returns

u8

Errors

  • traps when i >= byte_len(s), matching s.bytes()[i].
byte_slice :: fn(s: string, start: i64, end: i64) -> string

The bytes of s from offset start up to end, excluded, as a string: an @intrinsic slice of the interned atom, nothing copied. Offsets count bytes, where s[i] counts codepoints. Like any slice, offsets past the end clamp to it, and an end before start gives the empty string.

Parameters

sstring source string.
starti64 first byte offset, included.
endi64 byte offset where the slice stops, excluded.

Returns

string
is_ascii :: fn(s: string) -> bool

Whether every byte of s is ASCII (below 0x80): each byte is then one codepoint, and a byte offset is a codepoint index. The runtime records it when the string is made, so the answer reads no byte.

Parameters

sstring the string to test.

Returns

bool
write_string_at :: fn(self: Buffer, off: i64, s: string) -> i64

Write s's bytes at off ; return off + s.byte_len().

Parameters

selfBuffer No description.
offi64 No description.
sstring No description.

Returns

i64
write_int :: fn(self: Buffer, off: i64, n: i64) -> i64

Write the signed decimal digits of n at off ; return the offset past them.

Parameters

selfBuffer No description.
offi64 No description.
ni64 No description.

Returns

i64
write_unsigned :: fn(self: Buffer, off: i64, n: u64) -> i64

Write the unsigned decimal digits of n at off ; return the offset past them.

Parameters

selfBuffer No description.
offi64 No description.
nu64 No description.

Returns

i64
write_bool :: fn(self: Buffer, off: i64, b: bool) -> i64

Write "true" / "false" at off ; return the offset past it.

Parameters

selfBuffer No description.
offi64 No description.
bbool No description.

Returns

i64
bytes_to_string :: fn(bs: u8[]) -> string

Materialise a string from verbatim UTF-8 bytes: the canonical bytes→string primitive (inverse of bytes). Host intrinsic backed by vader_string_as_string (the runtime symbol kept its name) ; O(1) on a borrowed bytes() slice, O(n) on a packed array, no UTF-8 validation.

Parameters

bsu8[] the UTF-8 bytes to materialise (typically a bytes() slice).

Returns

string the string those bytes encode.
bytes :: fn(s: string) -> u8[]

Borrow the UTF-8 bytes of a string as a read-only u8[] view: the canonical string→bytes primitive, inverse of bytes_to_string. Host intrinsic backed by vader_string_bytes_view (no new runtime symbol) ; a zero-copy borrowed view of the interned bytes on native, read in place on the VM until a write copies it. To read a string's bytes, byte_len, byte_at and byte_slice take the string itself.

Parameters

sstring source string.

Returns

u8[] a read-only u8[] over the UTF-8 bytes of s.
is_utf8_continuation :: fn(b: u8) -> bool

True when b is a UTF-8 continuation byte (0x80..0xBF): the trailing bytes of a multi-byte sequence, never a leading byte.

Parameters

bu8 No description.

Returns

bool
utf8_encode :: fn(c: char) -> u8[]

Encode a Unicode codepoint to its UTF-8 bytes (pure arithmetic), for interning via bytes_to_string or appending into a byte buffer. codepoint_at_byte reads back what this writes.

Parameters

cchar the codepoint to encode.

Returns

u8[] the 1–4 UTF-8 bytes encoding c.
codepoint_at_byte :: fn(s: string, i: i64) -> [char, i64]

Decode the UTF-8 codepoint at byte offset i of a string, read in place: the codepoint and the bytes it spans. Advance a byte cursor by that width to land on the next codepoint. Malformed bytes decode as U+FFFD, spanning the longest prefix of a well-formed sequence and at least one byte: the substitution Unicode recommends and WHATWG decoders apply. Every codepoint walk in the standard library steps this way, so len, s[i] and for c in s agree on any bytes.

Parameters

sstring the source string.
ii64 byte offset. Traps if i >= s.byte_len().

Returns

[char, i64] [codepoint, byte_width], the width 1 to 4.

Example

[c, width] :: "é!".codepoint_at_byte(0)   // ['é', 2]
decode_tail :: fn(s: string, b: u8, i: i64) -> [u32, i64]

Decode the non-ASCII codepoint that b, the byte at offset i of s, leads: codepoint_at_byte past its ASCII test, for a walk that has read the byte.

Parameters

sstring the source string.
bu8 s.byte_at(i), at least 0x80.
ii64 the byte offset of b.

Returns

[u32, i64] [codepoint, byte_width], malformed bytes decoded as codepoint_at_byte does. The codepoint is a u32, a Unicode scalar value by the bytes it was read from: a caller wanting the char converts it.
len :: fn(s: string) -> i64

Codepoint length of s: the number of Unicode codepoints, not bytes. In the prelude, so s.len() works without importing std/string. Counts the steps of codepoint_at_byte over the bytes, so it is the number of codepoints for c in s yields. O(1) on an ASCII string, else O(n) in the byte length.

Parameters

sstring source string.

Returns

i64 the codepoint count.

Constants

POW5_128: u64[] :: @comptime { …

128-bit powers of five, POW5_128[2*(q+342)] = high word, +1 = low word. Computed at compile time ; see the file header for the algorithm.

REPLACEMENT_CHAR

const type inferred utf8.vader:14
REPLACEMENT_CHAR: char :: char(0xFFFD)

Unicode replacement character (U+FFFD): the standard stand-in for an undecodable byte or an unpaired UTF-16 surrogate.

Implementations

Methods

add :: fn(self, other: T[]) -> T[]
No description.

Methods

into :: fn(self) -> Iterator<T>
No description.

Membership for arrays: v in arr / v !in arr dispatch here. Linear scan via Equals. As an impl member, the monomorphised == devirtualises to the element's primitive comparison on every backend. Blanket impl (orphan rule : Contains is std/core's, T[] isn't), mirroring the Into blanket above.

Methods

contains :: fn(self, value: T) -> bool
No description.

[lhs] * n: array repeat / preallocation, the * operator on arrays. [v] * n repeats the elements n times ([7, 9] * 2 → [7, 9, 7, 9]) ; the empty-LHS form [] * n is the preallocation primitive (length 0, capacity n: the with_capacity replacement). * on an array dispatches here through the normal trait lookup : a concrete array matches this blanket via the "[]" impl-key (impl_base_key), and the lowerer devirtualises BOTH forms to the array.repeat intrinsic, which preserves the preallocation form and shallow ref-element semantics. The body is the logical repeat fallback for any path the devirt can't statically reach. The return is a fresh array the caller owns. Blanket impl (orphan rule : Mul is std/core's, T[] isn't), mirroring Into / Contains.

Methods

mul :: fn(self, other: i64) -> T[]
No description.

An array's text: [, then each element's own Display separated by , , then ]: [1, 2], [a, b], [[1], [2, 3]]. Each element is rendered once, then written into one buffer sized to fit them all.

Methods

to_string :: fn(self) -> string
No description.

Methods

into :: fn(self) -> string
No description.

Methods

to_string :: fn(self) -> string
No description.

Methods

to_string :: fn(self) -> string
No description.

Methods

to_string :: fn(self) -> string
No description.

Methods

to_string :: fn(self) -> string
No description.

Methods

to_string :: fn(self) -> string
No description.

Methods

to_string :: fn(self) -> string
No description.

Methods

to_string :: fn(self) -> string
No description.

Methods

to_string :: fn(self) -> string
No description.

Methods

to_string :: fn(self) -> string
No description.

Methods

to_string :: fn(self) -> string
No description.

Methods

to_string :: fn(self) -> string
No description.

Methods

to_string :: fn(self) -> string
No description.

Methods

to_string :: fn(self) -> string
No description.

Methods

to_string :: fn(self) -> string
No description.

Methods

hash :: fn(self) -> u64
No description.

Methods

hash :: fn(self) -> u64
No description.

Methods

hash :: fn(self) -> u64
No description.

Methods

hash :: fn(self) -> u64
No description.

Methods

hash :: fn(self) -> u64
No description.

Methods

hash :: fn(self) -> u64
No description.

Methods

hash :: fn(self) -> u64
No description.

Methods

hash :: fn(self) -> u64
No description.

Methods

hash :: fn(self) -> u64
No description.

Methods

compare :: fn(self, other: i8) -> i32
No description.

Methods

compare :: fn(self, other: i16) -> i32
No description.

Methods

compare :: fn(self, other: i32) -> i32
No description.

Methods

compare :: fn(self, other: i64) -> i32
No description.

Methods

compare :: fn(self, other: u8) -> i32
No description.

Methods

compare :: fn(self, other: u16) -> i32
No description.

Methods

compare :: fn(self, other: u32) -> i32
No description.

Methods

compare :: fn(self, other: u64) -> i32
No description.

Methods

compare :: fn(self, other: char) -> i32
No description.

Methods

step :: fn(self) -> i8
No description.

Methods

step :: fn(self) -> i16
No description.

Methods

step :: fn(self) -> i32
No description.

Methods

step :: fn(self) -> i64
No description.

Methods

step :: fn(self) -> u8
No description.

Methods

step :: fn(self) -> u16
No description.

Methods

step :: fn(self) -> u32
No description.

Methods

step :: fn(self) -> u64
No description.

Methods

step :: fn(self) -> char
No description.

Methods

zero :: fn() -> i8
No description.

Methods

zero :: fn() -> i16
No description.

Methods

zero :: fn() -> i32
No description.

Methods

zero :: fn() -> i64
No description.

Methods

zero :: fn() -> u8
No description.

Methods

zero :: fn() -> u16
No description.

Methods

zero :: fn() -> u32
No description.

Methods

zero :: fn() -> u64
No description.

Methods

zero :: fn() -> f32
No description.

Methods

zero :: fn() -> f64
No description.

Methods

one :: fn() -> i8
No description.

Methods

one :: fn() -> i16
No description.

Methods

one :: fn() -> i32
No description.

Methods

one :: fn() -> i64
No description.

Methods

one :: fn() -> u8
No description.

Methods

one :: fn() -> u16
No description.

Methods

one :: fn() -> u32
No description.

Methods

one :: fn() -> u64
No description.

Methods

one :: fn() -> f32
No description.

Methods

one :: fn() -> f64
No description.

Methods

add :: fn(self, other: string) -> string
No description.

s[i]: the codepoint at codepoint index i, found by walking s from its start; in an ASCII string, the byte at i. Traps past the last codepoint, where the walk lands on the length.

Methods

at :: fn(self, i: i64) -> char
No description.

s[lo..<hi] and s[lo..=hi]: the codepoints of a range, as a string; in an ASCII string, the bytes of the range. Bounds past the end clamp to it, and a range ending before it starts gives the empty string.

Methods

at :: fn(self, r: Range<i64>) -> string
No description.
Written by vader doc. Icons: Codicons, CC BY 4.0. Fonts: Atkinson Hyperlegible, JetBrains Mono, OFL.