1///|
2/// This package is based on the Go implementation found here:
3/// https://cs.opensource.google/go/go/+/master:src/encoding/base64/base64.go
4/// which has the copyright notice:
5/// Copyright 2009 The Go Authors. All rights reserved.
6/// Use of this source code is governed by a BSD-style
7/// license that can be found in the LICENSE file.
8pub(all) type! CorruptInputError 
String
String
derive(
(CorruptInputError, &Logger) -> Unit

Trait for types that can be converted to String

Show
)
9 10///| 11/// `std_decode2bytes` base64-decodes the provided bytes using Standard encoding. 12/// Setting `no_padding=true` is used for raw decoding. 13/// 14/// Note that standard encoding uses `+` and `/` characters whereas URL encoding uses `-` and `_`. 15/// 16/// Examples: 17/// ``` 18/// let b = "+/ Hello, δΈ–η•Œ! 🌍" 19/// inspect!(std_decode2bytes!("Ky8gSGVsbG8sIOS4lueVjCEg8J+MjQ==") |> bytes2str(), content=b) 20/// inspect!(std_decode2bytes!("Ky8gSGVsbG8sIOS4lueVjCEg8J+MjQ", no_padding=true) |> bytes2str(), content=b) 21/// ``` 22pub fn
(src : String, no_padding~ : Bool = ..) -> Bytes!CorruptInputError

std_decode2bytes base64-decodes the provided bytes using Standard encoding. Setting no_padding=true is used for raw decoding.

Note that standard encoding uses + and / characters whereas URL encoding uses - and _.

Examples:

let b = "+/ Hello, δΈ–η•Œ! 🌍"
inspect!(std_decode2bytes!("Ky8gSGVsbG8sIOS4lueVjCEg8J+MjQ==") |> bytes2str(), content=b)
inspect!(std_decode2bytes!("Ky8gSGVsbG8sIOS4lueVjCEg8J+MjQ", no_padding=true) |> bytes2str(), content=b)
std_decode2bytes
(
23
String
src
:
String
String
,
24
Bool
no_padding
~ :
Bool
Bool
= false
25) ->
Bytes
Bytes
!
type! CorruptInputError String

This package is based on the Go implementation found here: https://cs.opensource.google/go/go/+/master:src/encoding/base64/base64.go which has the copyright notice: Copyright 2009 The Go Authors. All rights reserved. Use of this source code is governed by a BSD-style license that can be found in the LICENSE file.

CorruptInputError
{
26 if
String
src
.
(self : String) -> Int

Returns the number of UTF-16 code units in the string. Note that this is not necessarily equal to the number of Unicode characters (code points) in the string, as some characters may be represented by multiple UTF-16 code units.

Parameters:

  • string : The string whose length is to be determined.

Returns the number of UTF-16 code units in the string.

Example:

test "String::length" {
  inspect("hello".length(), content="5")
  inspect("🀣".length(), content="2") // Emoji uses two UTF-16 code units
  inspect("".length(), content="0") // Empty string
}
length
()
(self : Int, other : Int) -> Bool

Compares two integers for equality.

Parameters:

  • self : The first integer to compare.
  • other : The second integer to compare.

Returns true if both integers have the same value, false otherwise.

Example:

test "Int::op_equal" {
  inspect(42 == 42, content="true")
  inspect(42 == -42, content="false")
}
==
0 {
27 return
(Array[Byte]) -> Bytes
Bytes::
(arr : Array[Byte]) -> Bytes

Creates a new bytes sequence from a byte array.

Parameters:

  • array : An array of bytes to be converted.

Returns a new bytes sequence containing the same bytes as the input array.

Example:

test "Bytes::from_array" {
  let arr = [b'h', b'i']
  let bytes = @bytes.from_array(arr)
  inspect(bytes, content=
    #|b"\x68\x69"
  )
}
from_array
([])
28 } 29 let
FixedArray[Byte]
buf
=
type FixedArray[A]
FixedArray
::
(len : Int, init : Byte) -> FixedArray[Byte]

Creates a new fixed-size array with the specified length, initializing all elements with the given value.

Parameters:

  • length : The length of the array to create. Must be non-negative.
  • initial_value : The value used to initialize all elements in the array.

Returns a new fixed-size array of type FixedArray[T] with length elements, where each element is initialized to initial_value.

Throws a panic if length is negative.

Example:

test "FixedArray::make" {
  let arr = FixedArray::make(3, 42)
  inspect(arr[0], content="42")
  inspect(arr.length(), content="3")
}

test "panic FixedArray::make/negative_length" {
  ignore(FixedArray::make(-1, 0))
}

WARNING: A common pitfall is creating with the same initial value, for example:

test {
  let two_dimension_array = FixedArray::make(10, FixedArray::make(10, 0))
  two_dimension_array[0][5] = 10
  assert_eq(two_dimension_array[5][5], 10)
}

This is because all the cells reference to the same object (the FixedArray[Int] in this case). One should use makei() instead which creates an object for each index.

make
(
(n : Int, no_padding : Bool) -> Int
decoded_len
(
String
src
.
(self : String) -> Int

Returns the number of UTF-16 code units in the string. Note that this is not necessarily equal to the number of Unicode characters (code points) in the string, as some characters may be represented by multiple UTF-16 code units.

Parameters:

  • string : The string whose length is to be determined.

Returns the number of UTF-16 code units in the string.

Example:

test "String::length" {
  inspect("hello".length(), content="5")
  inspect("🀣".length(), content="2") // Emoji uses two UTF-16 code units
  inspect("".length(), content="0") // Empty string
}
length
(),
Bool
no_padding
), b'\x00')
30 let
FixedArray[Byte]
src
=
type FixedArray[A]
FixedArray
::
(iter : Iter[Byte]) -> FixedArray[Byte]

Creates a new fixed array from an iterator.

Parameters:

  • iterator : An iterator of type Iter[T] from which elements will be collected into a fixed array.

Returns a new fixed array containing all elements from the iterator.

Example:

test "FixedArray::from_iter" {
  let arr = [1, 2, 3]
  let fixed_arr = FixedArray::from_iter(arr.iter())
  inspect(fixed_arr, content="[1, 2, 3]")
}
from_iter
(
(s : String) -> Bytes

str2bytes encodes a UTF-16 String as a UTF-8 Bytes.

Examples:

inspect!(str2bytes("+/ Hello, δΈ–η•Œ! 🌍"), content=
  #|b"\x2b\x2f\x20\x48\x65\x6c\x6c\x6f\x2c\x20\xe4\xb8\x96\xe7\x95\x8c\x21\x20\xf0\x9f\x8c\x8d"
)
str2bytes
(
String
src
).
(self : Bytes) -> Iter[Byte]

Creates an iterator over the bytes in the sequence.

Parameters:

  • bytes : A byte sequence to iterate over.

Returns an iterator that yields each byte in the sequence in order.

Example:

test "Bytes::iter" {
  let bytes = Bytes::from_array([b'h', b'i'])
  let mut sum = 0
  bytes.iter().each(fn(b) { sum = sum + b.to_int() })
  inspect(sum, content="209") // ASCII values: 'h'(104) + 'i'(105) = 209
}
iter
())
31 let
Int
n
=
(decode_map : FixedArray[Byte], dst : FixedArray[Byte], src : FixedArray[Byte], no_padding : Bool) -> Int!CorruptInputError
decode_buf
!(
FixedArray[Byte]
std_decode_map
,
FixedArray[Byte]
buf
,
FixedArray[Byte]
src
,
Bool
no_padding
)
32
(Iter[Byte]) -> Bytes
Bytes::
(iter : Iter[Byte]) -> Bytes

Creates a new bytes sequence from an iterator of bytes.

Parameters:

  • iterator : An iterator that yields bytes.

Returns a new bytes sequence containing all the bytes from the iterator.

Example:

test "from_iter" {
  let iter = Iter::singleton(b'h')
  let bytes = @bytes.from_iter(iter)
  inspect(bytes, content=
    #|b"\x68"
  )
}
from_iter
(
FixedArray[Byte]
buf
.
(self : FixedArray[Byte]) -> Iter[Byte]

Creates an iterator over the elements of a fixed-size array, providing sequential access to each element.

Parameters:

  • array : The fixed-size array to iterate over.

Returns an iterator that yields each element of the array in order from first to last.

Example:

test "FixedArray::iter" {
  let arr = FixedArray::make(3, 42)
  let mut sum = 0
  arr.iter().each(fn(x) { sum = sum + x })
  inspect(sum, content="126")
}
iter
().
(self : Iter[Byte], n : Int) -> Iter[Byte]

Takes the first n elements from the iterator.

Type Parameters

  • T: The type of the elements in the iterator.

Arguments

  • self - The input iterator.
  • n - The number of elements to take.

Returns

A new iterator that contains the first n elements.

take
(
Int
n
))
33} 34 35///| 36/// `std_decode2str` base64-decodes the provided bytes using Standard encoding and returns a String. 37/// Setting `no_padding=true` is used for raw decoding. 38/// 39/// Note that standard encoding uses `+` and `/` characters whereas URL encoding uses `-` and `_`. 40/// 41/// Examples: 42/// ``` 43/// let b = "+/ Hello, δΈ–η•Œ! 🌍" 44/// inspect!(std_decode2str!("Ky8gSGVsbG8sIOS4lueVjCEg8J+MjQ=="), content=b) 45/// inspect!(std_decode2str!("Ky8gSGVsbG8sIOS4lueVjCEg8J+MjQ", no_padding=true), content=b) 46/// ``` 47pub fn
(src : String, no_padding~ : Bool = ..) -> String!CorruptInputError

std_decode2str base64-decodes the provided bytes using Standard encoding and returns a String. Setting no_padding=true is used for raw decoding.

Note that standard encoding uses + and / characters whereas URL encoding uses - and _.

Examples:

let b = "+/ Hello, δΈ–η•Œ! 🌍"
inspect!(std_decode2str!("Ky8gSGVsbG8sIOS4lueVjCEg8J+MjQ=="), content=b)
inspect!(std_decode2str!("Ky8gSGVsbG8sIOS4lueVjCEg8J+MjQ", no_padding=true), content=b)
std_decode2str
(
48
String
src
:
String
String
,
49
Bool
no_padding
~ :
Bool
Bool
= false
50) ->
String
String
!
type! CorruptInputError String

This package is based on the Go implementation found here: https://cs.opensource.google/go/go/+/master:src/encoding/base64/base64.go which has the copyright notice: Copyright 2009 The Go Authors. All rights reserved. Use of this source code is governed by a BSD-style license that can be found in the LICENSE file.

CorruptInputError
{
51
(b : Bytes) -> String

bytes2str decodes a UTF-8 Bytes to a UTF-16 String.

Examples:

inspect!(bytes2str("+/ Hello, δΈ–η•Œ! 🌍"), content="+/ Hello, δΈ–η•Œ! 🌍")
bytes2str
(
(src : String, no_padding~ : Bool) -> Bytes!CorruptInputError

std_decode2bytes base64-decodes the provided bytes using Standard encoding. Setting no_padding=true is used for raw decoding.

Note that standard encoding uses + and / characters whereas URL encoding uses - and _.

Examples:

let b = "+/ Hello, δΈ–η•Œ! 🌍"
inspect!(std_decode2bytes!("Ky8gSGVsbG8sIOS4lueVjCEg8J+MjQ==") |> bytes2str(), content=b)
inspect!(std_decode2bytes!("Ky8gSGVsbG8sIOS4lueVjCEg8J+MjQ", no_padding=true) |> bytes2str(), content=b)
std_decode2bytes
!(
String
src
,
Bool
no_padding
~))
52} 53 54///| 55/// `url_decode2bytes` base64-decodes the provided bytes using URL encoding. 56/// Setting `no_padding=true` is used for raw decoding. 57/// 58/// Note that standard encoding uses `+` and `/` characters whereas URL encoding uses `-` and `_`. 59/// 60/// Examples: 61/// ``` 62/// let b = "+/ Hello, δΈ–η•Œ! 🌍" 63/// inspect!(url_decode2bytes!("Ky8gSGVsbG8sIOS4lueVjCEg8J-MjQ==") |> bytes2str(), content=b) 64/// inspect!(url_decode2bytes!("Ky8gSGVsbG8sIOS4lueVjCEg8J-MjQ", no_padding=true) |> bytes2str(), content=b) 65/// ``` 66pub fn
(src : String, no_padding~ : Bool = ..) -> Bytes!CorruptInputError

url_decode2bytes base64-decodes the provided bytes using URL encoding. Setting no_padding=true is used for raw decoding.

Note that standard encoding uses + and / characters whereas URL encoding uses - and _.

Examples:

let b = "+/ Hello, δΈ–η•Œ! 🌍"
inspect!(url_decode2bytes!("Ky8gSGVsbG8sIOS4lueVjCEg8J-MjQ==") |> bytes2str(), content=b)
inspect!(url_decode2bytes!("Ky8gSGVsbG8sIOS4lueVjCEg8J-MjQ", no_padding=true) |> bytes2str(), content=b)
url_decode2bytes
(
67
String
src
:
String
String
,
68
Bool
no_padding
~ :
Bool
Bool
= false
69) ->
Bytes
Bytes
!
type! CorruptInputError String

This package is based on the Go implementation found here: https://cs.opensource.google/go/go/+/master:src/encoding/base64/base64.go which has the copyright notice: Copyright 2009 The Go Authors. All rights reserved. Use of this source code is governed by a BSD-style license that can be found in the LICENSE file.

CorruptInputError
{
70 if
String
src
.
(self : String) -> Int

Returns the number of UTF-16 code units in the string. Note that this is not necessarily equal to the number of Unicode characters (code points) in the string, as some characters may be represented by multiple UTF-16 code units.

Parameters:

  • string : The string whose length is to be determined.

Returns the number of UTF-16 code units in the string.

Example:

test "String::length" {
  inspect("hello".length(), content="5")
  inspect("🀣".length(), content="2") // Emoji uses two UTF-16 code units
  inspect("".length(), content="0") // Empty string
}
length
()
(self : Int, other : Int) -> Bool

Compares two integers for equality.

Parameters:

  • self : The first integer to compare.
  • other : The second integer to compare.

Returns true if both integers have the same value, false otherwise.

Example:

test "Int::op_equal" {
  inspect(42 == 42, content="true")
  inspect(42 == -42, content="false")
}
==
0 {
71 return
(Array[Byte]) -> Bytes
Bytes::
(arr : Array[Byte]) -> Bytes

Creates a new bytes sequence from a byte array.

Parameters:

  • array : An array of bytes to be converted.

Returns a new bytes sequence containing the same bytes as the input array.

Example:

test "Bytes::from_array" {
  let arr = [b'h', b'i']
  let bytes = @bytes.from_array(arr)
  inspect(bytes, content=
    #|b"\x68\x69"
  )
}
from_array
([])
72 } 73 let
FixedArray[Byte]
buf
=
type FixedArray[A]
FixedArray
::
(len : Int, init : Byte) -> FixedArray[Byte]

Creates a new fixed-size array with the specified length, initializing all elements with the given value.

Parameters:

  • length : The length of the array to create. Must be non-negative.
  • initial_value : The value used to initialize all elements in the array.

Returns a new fixed-size array of type FixedArray[T] with length elements, where each element is initialized to initial_value.

Throws a panic if length is negative.

Example:

test "FixedArray::make" {
  let arr = FixedArray::make(3, 42)
  inspect(arr[0], content="42")
  inspect(arr.length(), content="3")
}

test "panic FixedArray::make/negative_length" {
  ignore(FixedArray::make(-1, 0))
}

WARNING: A common pitfall is creating with the same initial value, for example:

test {
  let two_dimension_array = FixedArray::make(10, FixedArray::make(10, 0))
  two_dimension_array[0][5] = 10
  assert_eq(two_dimension_array[5][5], 10)
}

This is because all the cells reference to the same object (the FixedArray[Int] in this case). One should use makei() instead which creates an object for each index.

make
(
(n : Int, no_padding : Bool) -> Int
decoded_len
(
String
src
.
(self : String) -> Int

Returns the number of UTF-16 code units in the string. Note that this is not necessarily equal to the number of Unicode characters (code points) in the string, as some characters may be represented by multiple UTF-16 code units.

Parameters:

  • string : The string whose length is to be determined.

Returns the number of UTF-16 code units in the string.

Example:

test "String::length" {
  inspect("hello".length(), content="5")
  inspect("🀣".length(), content="2") // Emoji uses two UTF-16 code units
  inspect("".length(), content="0") // Empty string
}
length
(),
Bool
no_padding
), b'\x00')
74 let
FixedArray[Byte]
src
=
type FixedArray[A]
FixedArray
::
(iter : Iter[Byte]) -> FixedArray[Byte]

Creates a new fixed array from an iterator.

Parameters:

  • iterator : An iterator of type Iter[T] from which elements will be collected into a fixed array.

Returns a new fixed array containing all elements from the iterator.

Example:

test "FixedArray::from_iter" {
  let arr = [1, 2, 3]
  let fixed_arr = FixedArray::from_iter(arr.iter())
  inspect(fixed_arr, content="[1, 2, 3]")
}
from_iter
(
(s : String) -> Bytes

str2bytes encodes a UTF-16 String as a UTF-8 Bytes.

Examples:

inspect!(str2bytes("+/ Hello, δΈ–η•Œ! 🌍"), content=
  #|b"\x2b\x2f\x20\x48\x65\x6c\x6c\x6f\x2c\x20\xe4\xb8\x96\xe7\x95\x8c\x21\x20\xf0\x9f\x8c\x8d"
)
str2bytes
(
String
src
).
(self : Bytes) -> Iter[Byte]

Creates an iterator over the bytes in the sequence.

Parameters:

  • bytes : A byte sequence to iterate over.

Returns an iterator that yields each byte in the sequence in order.

Example:

test "Bytes::iter" {
  let bytes = Bytes::from_array([b'h', b'i'])
  let mut sum = 0
  bytes.iter().each(fn(b) { sum = sum + b.to_int() })
  inspect(sum, content="209") // ASCII values: 'h'(104) + 'i'(105) = 209
}
iter
())
75 let
Int
n
=
(decode_map : FixedArray[Byte], dst : FixedArray[Byte], src : FixedArray[Byte], no_padding : Bool) -> Int!CorruptInputError
decode_buf
!(
FixedArray[Byte]
url_decode_map
,
FixedArray[Byte]
buf
,
FixedArray[Byte]
src
,
Bool
no_padding
)
76
(Iter[Byte]) -> Bytes
Bytes::
(iter : Iter[Byte]) -> Bytes

Creates a new bytes sequence from an iterator of bytes.

Parameters:

  • iterator : An iterator that yields bytes.

Returns a new bytes sequence containing all the bytes from the iterator.

Example:

test "from_iter" {
  let iter = Iter::singleton(b'h')
  let bytes = @bytes.from_iter(iter)
  inspect(bytes, content=
    #|b"\x68"
  )
}
from_iter
(
FixedArray[Byte]
buf
.
(self : FixedArray[Byte]) -> Iter[Byte]

Creates an iterator over the elements of a fixed-size array, providing sequential access to each element.

Parameters:

  • array : The fixed-size array to iterate over.

Returns an iterator that yields each element of the array in order from first to last.

Example:

test "FixedArray::iter" {
  let arr = FixedArray::make(3, 42)
  let mut sum = 0
  arr.iter().each(fn(x) { sum = sum + x })
  inspect(sum, content="126")
}
iter
().
(self : Iter[Byte], n : Int) -> Iter[Byte]

Takes the first n elements from the iterator.

Type Parameters

  • T: The type of the elements in the iterator.

Arguments

  • self - The input iterator.
  • n - The number of elements to take.

Returns

A new iterator that contains the first n elements.

take
(
Int
n
))
77} 78 79///| 80/// `url_decode2str` base64-decodes the provided bytes using URL encoding and returns a String. 81/// Setting `no_padding=true` is used for raw decoding. 82/// 83/// Note that standard encoding uses `+` and `/` characters whereas URL encoding uses `-` and `_`. 84/// 85/// Examples: 86/// ``` 87/// let b = "+/ Hello, δΈ–η•Œ! 🌍" 88/// inspect!(url_decode2str!("Ky8gSGVsbG8sIOS4lueVjCEg8J-MjQ=="), content=b) 89/// inspect!(url_decode2str!("Ky8gSGVsbG8sIOS4lueVjCEg8J-MjQ", no_padding=true), content=b) 90/// ``` 91pub fn
(src : String, no_padding~ : Bool = ..) -> String!CorruptInputError

url_decode2str base64-decodes the provided bytes using URL encoding and returns a String. Setting no_padding=true is used for raw decoding.

Note that standard encoding uses + and / characters whereas URL encoding uses - and _.

Examples:

let b = "+/ Hello, δΈ–η•Œ! 🌍"
inspect!(url_decode2str!("Ky8gSGVsbG8sIOS4lueVjCEg8J-MjQ=="), content=b)
inspect!(url_decode2str!("Ky8gSGVsbG8sIOS4lueVjCEg8J-MjQ", no_padding=true), content=b)
url_decode2str
(
92
String
src
:
String
String
,
93
Bool
no_padding
~ :
Bool
Bool
= false
94) ->
String
String
!
type! CorruptInputError String

This package is based on the Go implementation found here: https://cs.opensource.google/go/go/+/master:src/encoding/base64/base64.go which has the copyright notice: Copyright 2009 The Go Authors. All rights reserved. Use of this source code is governed by a BSD-style license that can be found in the LICENSE file.

CorruptInputError
{
95
(b : Bytes) -> String

bytes2str decodes a UTF-8 Bytes to a UTF-16 String.

Examples:

inspect!(bytes2str("+/ Hello, δΈ–η•Œ! 🌍"), content="+/ Hello, δΈ–η•Œ! 🌍")
bytes2str
(
(src : String, no_padding~ : Bool) -> Bytes!CorruptInputError

url_decode2bytes base64-decodes the provided bytes using URL encoding. Setting no_padding=true is used for raw decoding.

Note that standard encoding uses + and / characters whereas URL encoding uses - and _.

Examples:

let b = "+/ Hello, δΈ–η•Œ! 🌍"
inspect!(url_decode2bytes!("Ky8gSGVsbG8sIOS4lueVjCEg8J-MjQ==") |> bytes2str(), content=b)
inspect!(url_decode2bytes!("Ky8gSGVsbG8sIOS4lueVjCEg8J-MjQ", no_padding=true) |> bytes2str(), content=b)
url_decode2bytes
!(
String
src
,
Bool
no_padding
~))
96} 97 98///| 99fn
(decode_map : FixedArray[Byte], dst : FixedArray[Byte], dst_offset : Int, src : FixedArray[Byte], si : Int, decode_pad_char : Byte, no_padding : Bool) -> (Int, Int)!CorruptInputError
decode_quantum
(
100
FixedArray[Byte]
decode_map
:
type FixedArray[A]
FixedArray
[
Byte
Byte
],
101
FixedArray[Byte]
dst
:
type FixedArray[A]
FixedArray
[
Byte
Byte
],
102
Int
dst_offset
:
Int
Int
,
103
FixedArray[Byte]
src
:
type FixedArray[A]
FixedArray
[
Byte
Byte
],
104
Int
si
:
Int
Int
,
105
Byte
decode_pad_char
:
Byte
Byte
,
106
Bool
no_padding
:
Bool
Bool
107) -> (
Int
Int
,
Int
Int
)!
type! CorruptInputError String

This package is based on the Go implementation found here: https://cs.opensource.google/go/go/+/master:src/encoding/base64/base64.go which has the copyright notice: Copyright 2009 The Go Authors. All rights reserved. Use of this source code is governed by a BSD-style license that can be found in the LICENSE file.

CorruptInputError
{
108 let
FixedArray[Byte]
dbuf
:
type FixedArray[A]
FixedArray
[
Byte
Byte
] =
type FixedArray[A]
FixedArray
::
(len : Int, init : Byte) -> FixedArray[Byte]

Creates a new fixed-size array with the specified length, initializing all elements with the given value.

Parameters:

  • length : The length of the array to create. Must be non-negative.
  • initial_value : The value used to initialize all elements in the array.

Returns a new fixed-size array of type FixedArray[T] with length elements, where each element is initialized to initial_value.

Throws a panic if length is negative.

Example:

test "FixedArray::make" {
  let arr = FixedArray::make(3, 42)
  inspect(arr[0], content="42")
  inspect(arr.length(), content="3")
}

test "panic FixedArray::make/negative_length" {
  ignore(FixedArray::make(-1, 0))
}

WARNING: A common pitfall is creating with the same initial value, for example:

test {
  let two_dimension_array = FixedArray::make(10, FixedArray::make(10, 0))
  two_dimension_array[0][5] = 10
  assert_eq(two_dimension_array[5][5], 10)
}

This is because all the cells reference to the same object (the FixedArray[Int] in this case). One should use makei() instead which creates an object for each index.

make
(4, b'\x00')
109 let mut
Int
dlen
= 4
110 let mut
Int
si
=
Int
si
111 for
Int
j
= 0;
Int
j
(self_ : Int, other : Int) -> Bool
<
4;
Int
j
=
Int
j
(self : Int, other : Int) -> Int

Adds two 32-bit signed integers. Performs two's complement arithmetic, which means the operation will wrap around if the result exceeds the range of a 32-bit integer.

Parameters:

  • self : The first integer operand.
  • other : The second integer operand.

Returns a new integer that is the sum of the two operands. If the mathematical sum exceeds the range of a 32-bit integer (-2,147,483,648 to 2,147,483,647), the result wraps around according to two's complement rules.

Example:

test "Int::op_add" {
  inspect(42 + 1, content="43")
  inspect(2147483647 + 1, content="-2147483648") // Overflow wraps around to minimum value
}
+
1 {
112 if
FixedArray[Byte]
src
.
(self : FixedArray[Byte]) -> Int

Returns the number of elements in a fixed-size array.

Parameters:

  • array : The fixed-size array whose length is to be determined.

Returns an integer representing the number of elements in the array.

Example:

test "FixedArray::length" {
  let arr = FixedArray::make(3, 42)
  inspect(arr.length(), content="3")
}
length
()
(self : Int, other : Int) -> Bool

Compares two integers for equality.

Parameters:

  • self : The first integer to compare.
  • other : The second integer to compare.

Returns true if both integers have the same value, false otherwise.

Example:

test "Int::op_equal" {
  inspect(42 == 42, content="true")
  inspect(42 == -42, content="false")
}
==
Int
si
{
113 if
Int
j
(self : Int, other : Int) -> Bool

Compares two integers for equality.

Parameters:

  • self : The first integer to compare.
  • other : The second integer to compare.

Returns true if both integers have the same value, false otherwise.

Example:

test "Int::op_equal" {
  inspect(42 == 42, content="true")
  inspect(42 == -42, content="false")
}
==
0 {
114 return (
Int
si
, 0)
115 } 116 if
Int
j
(self : Int, other : Int) -> Bool

Compares two integers for equality.

Parameters:

  • self : The first integer to compare.
  • other : The second integer to compare.

Returns true if both integers have the same value, false otherwise.

Example:

test "Int::op_equal" {
  inspect(42 == 42, content="true")
  inspect(42 == -42, content="false")
}
==
1
(Bool, Bool) -> Bool
||
(x : Bool) -> Bool

Performs logical negation on a boolean value.

Parameters:

  • value : The boolean value to negate.

Returns the logical NOT of the input value: true if the input is false, and false if the input is true.

Example:

test "not" {
  inspect(not(true), content="false")
  inspect(not(false), content="true")
}
not
(
Bool
no_padding
) {
117 let
Int
pos
=
Int
si
(self : Int, other : Int) -> Int

Performs subtraction between two 32-bit integers, following standard two's complement arithmetic rules. When the result overflows or underflows, it wraps around within the 32-bit integer range.

Parameters:

  • self : The minuend (the number being subtracted from).
  • other : The subtrahend (the number to subtract).

Returns the difference between self and other.

Example:

test "Int::op_sub" {
  let a = 42
  let b = 10
  inspect(a - b, content="32")
  let max = 2147483647 // Int maximum value
  inspect(max - -1, content="-2147483648") // Overflow case
}
-
Int
j
118 raise
(String) -> CorruptInputError

This package is based on the Go implementation found here: https://cs.opensource.google/go/go/+/master:src/encoding/base64/base64.go which has the copyright notice: Copyright 2009 The Go Authors. All rights reserved. Use of this source code is governed by a BSD-style license that can be found in the LICENSE file.

CorruptInputError
("illegal base64 data at input byte \{
Int
pos
}")
119 } 120
Int
dlen
=
Int
j
121 break 122 } 123 let
Byte
in_byte
=
FixedArray[Byte]
src
(FixedArray[Byte], Int) -> Byte

Retrieves an element at the specified index from a fixed-size array. This function implements the array indexing operator [].

Parameters:

  • array : The fixed-size array to access.
  • index : The position in the array from which to retrieve the element.

Returns the element at the specified index.

Throws a runtime error if the index is out of bounds (negative or greater than or equal to the length of the array).

Example:

test "FixedArray::op_get" {
  let arr = FixedArray::make(3, 42)
  inspect(arr[1], content="42")
}

test "panic FixedArray::op_get/out_of_bounds" {
  let arr = FixedArray::make(3, 0)
  ignore(arr[3]) // Index out of bounds
}
[
si]
124
Int
si
(self : Int, other : Int) -> Int

Adds two 32-bit signed integers. Performs two's complement arithmetic, which means the operation will wrap around if the result exceeds the range of a 32-bit integer.

Parameters:

  • self : The first integer operand.
  • other : The second integer operand.

Returns a new integer that is the sum of the two operands. If the mathematical sum exceeds the range of a 32-bit integer (-2,147,483,648 to 2,147,483,647), the result wraps around according to two's complement rules.

Example:

test "Int::op_add" {
  inspect(42 + 1, content="43")
  inspect(2147483647 + 1, content="-2147483648") // Overflow wraps around to minimum value
}
+=
1
125 let
Byte
out
=
FixedArray[Byte]
decode_map
(FixedArray[Byte], Int) -> Byte

Retrieves an element at the specified index from a fixed-size array. This function implements the array indexing operator [].

Parameters:

  • array : The fixed-size array to access.
  • index : The position in the array from which to retrieve the element.

Returns the element at the specified index.

Throws a runtime error if the index is out of bounds (negative or greater than or equal to the length of the array).

Example:

test "FixedArray::op_get" {
  let arr = FixedArray::make(3, 42)
  inspect(arr[1], content="42")
}

test "panic FixedArray::op_get/out_of_bounds" {
  let arr = FixedArray::make(3, 0)
  ignore(arr[3]) // Index out of bounds
}
[
in_byte.
(self : Byte) -> Int

Converts a byte value to a 32-bit signed integer. The resulting integer will have the same binary representation as the byte value, preserving the numerical value in the range [0, 255].

Parameters:

  • byte : The byte value to be converted to an integer.

Returns a 32-bit signed integer representing the same numerical value as the input byte.

Example:

test "Byte::to_int" {
  let b = b'\xFF' // byte with value 255
  inspect(b.to_int(), content="255")
  let zero = b'\x00'
  inspect(zero.to_int(), content="0")
}
to_int
()]
126 if
Byte
out
(x : Byte, y : Byte) -> Bool
!=
b'\xff' {
127
FixedArray[Byte]
dbuf
(FixedArray[Byte], Int, Byte) -> Unit

Sets a value at the specified index in a fixed-size array. The original value at that index is overwritten.

Parameters:

  • array : The fixed-size array to modify.
  • index : The position in the array where the value will be set.
  • value : The new value to assign at the specified index.

Throws a runtime error if the index is out of bounds (less than 0 or greater than or equal to the length of the array).

Example:

test "FixedArray::op_set" {
  let arr = [1, 2, 3]
  arr[1] = 42
  inspect(arr, content="[1, 42, 3]")
}

test "panic FixedArray::op_set/out_of_bounds" {
  let arr = [1, 2, 3]
  arr[3] = 42 // Index out of bounds
}
[
j] =
Byte
out
128 continue 129 } 130 if
Byte
in_byte
(self : Byte, that : Byte) -> Bool

Compares two Byte values for equality.

Parameters:

  • self : The first Byte value to compare.
  • that : The second Byte value to compare.

Returns true if the two Byte values are equal, otherwise false.

==
b'\x0a'
(Bool, Bool) -> Bool
||
Byte
in_byte
(self : Byte, that : Byte) -> Bool

Compares two Byte values for equality.

Parameters:

  • self : The first Byte value to compare.
  • that : The second Byte value to compare.

Returns true if the two Byte values are equal, otherwise false.

==
b'\x0d' {
131 continue
Int
j
(self : Int, other : Int) -> Int

Performs subtraction between two 32-bit integers, following standard two's complement arithmetic rules. When the result overflows or underflows, it wraps around within the 32-bit integer range.

Parameters:

  • self : The minuend (the number being subtracted from).
  • other : The subtrahend (the number to subtract).

Returns the difference between self and other.

Example:

test "Int::op_sub" {
  let a = 42
  let b = 10
  inspect(a - b, content="32")
  let max = 2147483647 // Int maximum value
  inspect(max - -1, content="-2147483648") // Overflow case
}
-
1
132 } 133 if
Byte
in_byte
(x : Byte, y : Byte) -> Bool
!=
Byte
decode_pad_char
{
134 let
Int
pos
=
Int
si
(self : Int, other : Int) -> Int

Performs subtraction between two 32-bit integers, following standard two's complement arithmetic rules. When the result overflows or underflows, it wraps around within the 32-bit integer range.

Parameters:

  • self : The minuend (the number being subtracted from).
  • other : The subtrahend (the number to subtract).

Returns the difference between self and other.

Example:

test "Int::op_sub" {
  let a = 42
  let b = 10
  inspect(a - b, content="32")
  let max = 2147483647 // Int maximum value
  inspect(max - -1, content="-2147483648") // Overflow case
}
-
1
135 raise
(String) -> CorruptInputError

This package is based on the Go implementation found here: https://cs.opensource.google/go/go/+/master:src/encoding/base64/base64.go which has the copyright notice: Copyright 2009 The Go Authors. All rights reserved. Use of this source code is governed by a BSD-style license that can be found in the LICENSE file.

CorruptInputError
("expected pad characted at input byte \{
Int
pos
}")
136 } 137 138 // We've reached the end and there's padding 139 if
Int
j
(self : Int, other : Int) -> Bool

Compares two integers for equality.

Parameters:

  • self : The first integer to compare.
  • other : The second integer to compare.

Returns true if both integers have the same value, false otherwise.

Example:

test "Int::op_equal" {
  inspect(42 == 42, content="true")
  inspect(42 == -42, content="false")
}
==
0
(Bool, Bool) -> Bool
||
Int
j
(self : Int, other : Int) -> Bool

Compares two integers for equality.

Parameters:

  • self : The first integer to compare.
  • other : The second integer to compare.

Returns true if both integers have the same value, false otherwise.

Example:

test "Int::op_equal" {
  inspect(42 == 42, content="true")
  inspect(42 == -42, content="false")
}
==
1 {
140 let
Int
pos
=
Int
si
(self : Int, other : Int) -> Int

Performs subtraction between two 32-bit integers, following standard two's complement arithmetic rules. When the result overflows or underflows, it wraps around within the 32-bit integer range.

Parameters:

  • self : The minuend (the number being subtracted from).
  • other : The subtrahend (the number to subtract).

Returns the difference between self and other.

Example:

test "Int::op_sub" {
  let a = 42
  let b = 10
  inspect(a - b, content="32")
  let max = 2147483647 // Int maximum value
  inspect(max - -1, content="-2147483648") // Overflow case
}
-
1
141 raise
(String) -> CorruptInputError

This package is based on the Go implementation found here: https://cs.opensource.google/go/go/+/master:src/encoding/base64/base64.go which has the copyright notice: Copyright 2009 The Go Authors. All rights reserved. Use of this source code is governed by a BSD-style license that can be found in the LICENSE file.

CorruptInputError
("incorrect padding at input byte \{
Int
pos
}")
142 } 143 if
Int
j
(self : Int, other : Int) -> Bool

Compares two integers for equality.

Parameters:

  • self : The first integer to compare.
  • other : The second integer to compare.

Returns true if both integers have the same value, false otherwise.

Example:

test "Int::op_equal" {
  inspect(42 == 42, content="true")
  inspect(42 == -42, content="false")
}
==
2 {
144 // "==" is expected, the first "=" is already consumed. 145 // skip over newlines 146 for ;
Int
si
(self_ : Int, other : Int) -> Bool
<
FixedArray[Byte]
src
.
(self : FixedArray[Byte]) -> Int

Returns the number of elements in a fixed-size array.

Parameters:

  • array : The fixed-size array whose length is to be determined.

Returns an integer representing the number of elements in the array.

Example:

test "FixedArray::length" {
  let arr = FixedArray::make(3, 42)
  inspect(arr.length(), content="3")
}
length
()
(Bool, Bool) -> Bool
&&
(
FixedArray[Byte]
src
(FixedArray[Byte], Int) -> Byte

Retrieves an element at the specified index from a fixed-size array. This function implements the array indexing operator [].

Parameters:

  • array : The fixed-size array to access.
  • index : The position in the array from which to retrieve the element.

Returns the element at the specified index.

Throws a runtime error if the index is out of bounds (negative or greater than or equal to the length of the array).

Example:

test "FixedArray::op_get" {
  let arr = FixedArray::make(3, 42)
  inspect(arr[1], content="42")
}

test "panic FixedArray::op_get/out_of_bounds" {
  let arr = FixedArray::make(3, 0)
  ignore(arr[3]) // Index out of bounds
}
[
si]
(self : Byte, that : Byte) -> Bool

Compares two Byte values for equality.

Parameters:

  • self : The first Byte value to compare.
  • that : The second Byte value to compare.

Returns true if the two Byte values are equal, otherwise false.

==
b'\x0a'
(Bool, Bool) -> Bool
||
FixedArray[Byte]
src
(FixedArray[Byte], Int) -> Byte

Retrieves an element at the specified index from a fixed-size array. This function implements the array indexing operator [].

Parameters:

  • array : The fixed-size array to access.
  • index : The position in the array from which to retrieve the element.

Returns the element at the specified index.

Throws a runtime error if the index is out of bounds (negative or greater than or equal to the length of the array).

Example:

test "FixedArray::op_get" {
  let arr = FixedArray::make(3, 42)
  inspect(arr[1], content="42")
}

test "panic FixedArray::op_get/out_of_bounds" {
  let arr = FixedArray::make(3, 0)
  ignore(arr[3]) // Index out of bounds
}
[
si]
(self : Byte, that : Byte) -> Bool

Compares two Byte values for equality.

Parameters:

  • self : The first Byte value to compare.
  • that : The second Byte value to compare.

Returns true if the two Byte values are equal, otherwise false.

==
b'\x0d'); {
147
Int
si
(self : Int, other : Int) -> Int

Adds two 32-bit signed integers. Performs two's complement arithmetic, which means the operation will wrap around if the result exceeds the range of a 32-bit integer.

Parameters:

  • self : The first integer operand.
  • other : The second integer operand.

Returns a new integer that is the sum of the two operands. If the mathematical sum exceeds the range of a 32-bit integer (-2,147,483,648 to 2,147,483,647), the result wraps around according to two's complement rules.

Example:

test "Int::op_add" {
  inspect(42 + 1, content="43")
  inspect(2147483647 + 1, content="-2147483648") // Overflow wraps around to minimum value
}
+=
1
148 } 149 if
Int
si
(self : Int, other : Int) -> Bool

Compares two integers for equality.

Parameters:

  • self : The first integer to compare.
  • other : The second integer to compare.

Returns true if both integers have the same value, false otherwise.

Example:

test "Int::op_equal" {
  inspect(42 == 42, content="true")
  inspect(42 == -42, content="false")
}
==
FixedArray[Byte]
src
.
(self : FixedArray[Byte]) -> Int

Returns the number of elements in a fixed-size array.

Parameters:

  • array : The fixed-size array whose length is to be determined.

Returns an integer representing the number of elements in the array.

Example:

test "FixedArray::length" {
  let arr = FixedArray::make(3, 42)
  inspect(arr.length(), content="3")
}
length
() {
150 // not enough padding 151 let
Int
pos
=
FixedArray[Byte]
src
.
(self : FixedArray[Byte]) -> Int

Returns the number of elements in a fixed-size array.

Parameters:

  • array : The fixed-size array whose length is to be determined.

Returns an integer representing the number of elements in the array.

Example:

test "FixedArray::length" {
  let arr = FixedArray::make(3, 42)
  inspect(arr.length(), content="3")
}
length
()
152 raise
(String) -> CorruptInputError

This package is based on the Go implementation found here: https://cs.opensource.google/go/go/+/master:src/encoding/base64/base64.go which has the copyright notice: Copyright 2009 The Go Authors. All rights reserved. Use of this source code is governed by a BSD-style license that can be found in the LICENSE file.

CorruptInputError
("not enough padding at \{
Int
pos
}")
153 } 154 if
FixedArray[Byte]
src
(FixedArray[Byte], Int) -> Byte

Retrieves an element at the specified index from a fixed-size array. This function implements the array indexing operator [].

Parameters:

  • array : The fixed-size array to access.
  • index : The position in the array from which to retrieve the element.

Returns the element at the specified index.

Throws a runtime error if the index is out of bounds (negative or greater than or equal to the length of the array).

Example:

test "FixedArray::op_get" {
  let arr = FixedArray::make(3, 42)
  inspect(arr[1], content="42")
}

test "panic FixedArray::op_get/out_of_bounds" {
  let arr = FixedArray::make(3, 0)
  ignore(arr[3]) // Index out of bounds
}
[
si]
(x : Byte, y : Byte) -> Bool
!=
Byte
decode_pad_char
{
155 // incorrect padding 156 let
Int
pos
=
Int
si
(self : Int, other : Int) -> Int

Performs subtraction between two 32-bit integers, following standard two's complement arithmetic rules. When the result overflows or underflows, it wraps around within the 32-bit integer range.

Parameters:

  • self : The minuend (the number being subtracted from).
  • other : The subtrahend (the number to subtract).

Returns the difference between self and other.

Example:

test "Int::op_sub" {
  let a = 42
  let b = 10
  inspect(a - b, content="32")
  let max = 2147483647 // Int maximum value
  inspect(max - -1, content="-2147483648") // Overflow case
}
-
1
157 raise
(String) -> CorruptInputError

This package is based on the Go implementation found here: https://cs.opensource.google/go/go/+/master:src/encoding/base64/base64.go which has the copyright notice: Copyright 2009 The Go Authors. All rights reserved. Use of this source code is governed by a BSD-style license that can be found in the LICENSE file.

CorruptInputError
("incorrect padding at \{
Int
pos
}")
158 } 159
Int
si
(self : Int, other : Int) -> Int

Adds two 32-bit signed integers. Performs two's complement arithmetic, which means the operation will wrap around if the result exceeds the range of a 32-bit integer.

Parameters:

  • self : The first integer operand.
  • other : The second integer operand.

Returns a new integer that is the sum of the two operands. If the mathematical sum exceeds the range of a 32-bit integer (-2,147,483,648 to 2,147,483,647), the result wraps around according to two's complement rules.

Example:

test "Int::op_add" {
  inspect(42 + 1, content="43")
  inspect(2147483647 + 1, content="-2147483648") // Overflow wraps around to minimum value
}
+=
1
160 } 161 162 // skip over newlines 163 for ;
Int
si
(self_ : Int, other : Int) -> Bool
<
FixedArray[Byte]
src
.
(self : FixedArray[Byte]) -> Int

Returns the number of elements in a fixed-size array.

Parameters:

  • array : The fixed-size array whose length is to be determined.

Returns an integer representing the number of elements in the array.

Example:

test "FixedArray::length" {
  let arr = FixedArray::make(3, 42)
  inspect(arr.length(), content="3")
}
length
()
(Bool, Bool) -> Bool
&&
(
FixedArray[Byte]
src
(FixedArray[Byte], Int) -> Byte

Retrieves an element at the specified index from a fixed-size array. This function implements the array indexing operator [].

Parameters:

  • array : The fixed-size array to access.
  • index : The position in the array from which to retrieve the element.

Returns the element at the specified index.

Throws a runtime error if the index is out of bounds (negative or greater than or equal to the length of the array).

Example:

test "FixedArray::op_get" {
  let arr = FixedArray::make(3, 42)
  inspect(arr[1], content="42")
}

test "panic FixedArray::op_get/out_of_bounds" {
  let arr = FixedArray::make(3, 0)
  ignore(arr[3]) // Index out of bounds
}
[
si]
(self : Byte, that : Byte) -> Bool

Compares two Byte values for equality.

Parameters:

  • self : The first Byte value to compare.
  • that : The second Byte value to compare.

Returns true if the two Byte values are equal, otherwise false.

==
b'\x0a'
(Bool, Bool) -> Bool
||
FixedArray[Byte]
src
(FixedArray[Byte], Int) -> Byte

Retrieves an element at the specified index from a fixed-size array. This function implements the array indexing operator [].

Parameters:

  • array : The fixed-size array to access.
  • index : The position in the array from which to retrieve the element.

Returns the element at the specified index.

Throws a runtime error if the index is out of bounds (negative or greater than or equal to the length of the array).

Example:

test "FixedArray::op_get" {
  let arr = FixedArray::make(3, 42)
  inspect(arr[1], content="42")
}

test "panic FixedArray::op_get/out_of_bounds" {
  let arr = FixedArray::make(3, 0)
  ignore(arr[3]) // Index out of bounds
}
[
si]
(self : Byte, that : Byte) -> Bool

Compares two Byte values for equality.

Parameters:

  • self : The first Byte value to compare.
  • that : The second Byte value to compare.

Returns true if the two Byte values are equal, otherwise false.

==
b'\x0d'); {
164
Int
si
(self : Int, other : Int) -> Int

Adds two 32-bit signed integers. Performs two's complement arithmetic, which means the operation will wrap around if the result exceeds the range of a 32-bit integer.

Parameters:

  • self : The first integer operand.
  • other : The second integer operand.

Returns a new integer that is the sum of the two operands. If the mathematical sum exceeds the range of a 32-bit integer (-2,147,483,648 to 2,147,483,647), the result wraps around according to two's complement rules.

Example:

test "Int::op_add" {
  inspect(42 + 1, content="43")
  inspect(2147483647 + 1, content="-2147483648") // Overflow wraps around to minimum value
}
+=
1
165 } 166 if
Int
si
(self_ : Int, other : Int) -> Bool
<
FixedArray[Byte]
src
.
(self : FixedArray[Byte]) -> Int

Returns the number of elements in a fixed-size array.

Parameters:

  • array : The fixed-size array whose length is to be determined.

Returns an integer representing the number of elements in the array.

Example:

test "FixedArray::length" {
  let arr = FixedArray::make(3, 42)
  inspect(arr.length(), content="3")
}
length
() {
167 // trailing garbage 168 raise
(String) -> CorruptInputError

This package is based on the Go implementation found here: https://cs.opensource.google/go/go/+/master:src/encoding/base64/base64.go which has the copyright notice: Copyright 2009 The Go Authors. All rights reserved. Use of this source code is governed by a BSD-style license that can be found in the LICENSE file.

CorruptInputError
("trailing garbage at \{
Int
si
}")
169 } 170
Int
dlen
=
Int
j
171 break 172 } 173 174 // Convert 4x 6bit source bytes into 3 bytes 175 let
UInt
val
= (
FixedArray[Byte]
dbuf
[0].
(self : Byte) -> UInt

Converts a Byte to a UInt.

Parameters:

  • byte : The Byte value to be converted.

Returns the UInt representation of the Byte.

to_uint
()
(self : UInt, shift : Int) -> UInt

Performs a left shift operation on an unsigned 32-bit integer. Each bit in the integer is shifted left by the specified number of positions, and zeros are filled in from the right.

Parameters:

  • self : The unsigned 32-bit integer to be shifted.
  • shift : The number of positions to shift. Only the least significant 5 bits are used, effectively making the shift count always between 0 and 31.

Returns a new unsigned 32-bit integer that is the result of shifting self left by shift positions.

Example:

test "UInt::op_shl" {
  let x = 1U
  inspect(x << 3, content="8") // Binary: 1 -> 1000
  let y = 0xFFFFFFFFU
  inspect(y << 16, content="4294901760") // All bits after position 16 are discarded
}
<<
18)
(UInt, UInt) -> UInt
|
176 (
FixedArray[Byte]
dbuf
[1].
(self : Byte) -> UInt

Converts a Byte to a UInt.

Parameters:

  • byte : The Byte value to be converted.

Returns the UInt representation of the Byte.

to_uint
()
(self : UInt, shift : Int) -> UInt

Performs a left shift operation on an unsigned 32-bit integer. Each bit in the integer is shifted left by the specified number of positions, and zeros are filled in from the right.

Parameters:

  • self : The unsigned 32-bit integer to be shifted.
  • shift : The number of positions to shift. Only the least significant 5 bits are used, effectively making the shift count always between 0 and 31.

Returns a new unsigned 32-bit integer that is the result of shifting self left by shift positions.

Example:

test "UInt::op_shl" {
  let x = 1U
  inspect(x << 3, content="8") // Binary: 1 -> 1000
  let y = 0xFFFFFFFFU
  inspect(y << 16, content="4294901760") // All bits after position 16 are discarded
}
<<
12)
(UInt, UInt) -> UInt
|
177 (
FixedArray[Byte]
dbuf
[2].
(self : Byte) -> UInt

Converts a Byte to a UInt.

Parameters:

  • byte : The Byte value to be converted.

Returns the UInt representation of the Byte.

to_uint
()
(self : UInt, shift : Int) -> UInt

Performs a left shift operation on an unsigned 32-bit integer. Each bit in the integer is shifted left by the specified number of positions, and zeros are filled in from the right.

Parameters:

  • self : The unsigned 32-bit integer to be shifted.
  • shift : The number of positions to shift. Only the least significant 5 bits are used, effectively making the shift count always between 0 and 31.

Returns a new unsigned 32-bit integer that is the result of shifting self left by shift positions.

Example:

test "UInt::op_shl" {
  let x = 1U
  inspect(x << 3, content="8") // Binary: 1 -> 1000
  let y = 0xFFFFFFFFU
  inspect(y << 16, content="4294901760") // All bits after position 16 are discarded
}
<<
6)
(UInt, UInt) -> UInt
|
178
FixedArray[Byte]
dbuf
[3].
(self : Byte) -> UInt

Converts a Byte to a UInt.

Parameters:

  • byte : The Byte value to be converted.

Returns the UInt representation of the Byte.

to_uint
()
179
FixedArray[Byte]
dbuf
[2] = (
UInt
val
(self : UInt, shift : Int) -> UInt

Performs a logical right shift operation on an unsigned 32-bit integer. The operation shifts all bits to the right by a specified number of positions, filling the leftmost positions with zeros.

Parameters:

  • self : The unsigned 32-bit integer to be shifted.
  • shift : The number of positions to shift right. If this value is negative, the behavior is undefined. Values larger than 31 are masked with & 31.

Returns a new unsigned 32-bit integer containing the result of the right shift operation.

Example:

test "UInt::op_shr" {
  let x = 0xFF000000U
  inspect(x >> 8, content="16711680") // 0x00FF0000
  inspect(x >> 24, content="255") // 0x000000FF
}

test "UInt::op_shr/large_shift" {
  let x = 0xFF000000U
  inspect(x >> 32, content="4278190080") // Same as x >> 0 due to masking
}
>>
0).
(self : UInt) -> Byte

Converts an unsigned 32-bit integer to a byte by taking its least significant 8 bits. Any bits beyond the first 8 bits are truncated.

Parameters:

  • self : The unsigned 32-bit integer to be converted. Only the least significant 8 bits will be used.

Returns a byte containing the least significant 8 bits of the input integer.

Example:

test "UInt::to_byte" {
  let n = 258U // In binary: 100000010
  inspect(n.to_byte(), content="b'\\x02'") // Only keeps 00000010
  let big = 4294967295U // Maximum value of UInt
  inspect(big.to_byte(), content="b'\\xFF'") // Only keeps 11111111
}
to_byte
()
180
FixedArray[Byte]
dbuf
[1] = (
UInt
val
(self : UInt, shift : Int) -> UInt

Performs a logical right shift operation on an unsigned 32-bit integer. The operation shifts all bits to the right by a specified number of positions, filling the leftmost positions with zeros.

Parameters:

  • self : The unsigned 32-bit integer to be shifted.
  • shift : The number of positions to shift right. If this value is negative, the behavior is undefined. Values larger than 31 are masked with & 31.

Returns a new unsigned 32-bit integer containing the result of the right shift operation.

Example:

test "UInt::op_shr" {
  let x = 0xFF000000U
  inspect(x >> 8, content="16711680") // 0x00FF0000
  inspect(x >> 24, content="255") // 0x000000FF
}

test "UInt::op_shr/large_shift" {
  let x = 0xFF000000U
  inspect(x >> 32, content="4278190080") // Same as x >> 0 due to masking
}
>>
8).
(self : UInt) -> Byte

Converts an unsigned 32-bit integer to a byte by taking its least significant 8 bits. Any bits beyond the first 8 bits are truncated.

Parameters:

  • self : The unsigned 32-bit integer to be converted. Only the least significant 8 bits will be used.

Returns a byte containing the least significant 8 bits of the input integer.

Example:

test "UInt::to_byte" {
  let n = 258U // In binary: 100000010
  inspect(n.to_byte(), content="b'\\x02'") // Only keeps 00000010
  let big = 4294967295U // Maximum value of UInt
  inspect(big.to_byte(), content="b'\\xFF'") // Only keeps 11111111
}
to_byte
()
181
FixedArray[Byte]
dbuf
[0] = (
UInt
val
(self : UInt, shift : Int) -> UInt

Performs a logical right shift operation on an unsigned 32-bit integer. The operation shifts all bits to the right by a specified number of positions, filling the leftmost positions with zeros.

Parameters:

  • self : The unsigned 32-bit integer to be shifted.
  • shift : The number of positions to shift right. If this value is negative, the behavior is undefined. Values larger than 31 are masked with & 31.

Returns a new unsigned 32-bit integer containing the result of the right shift operation.

Example:

test "UInt::op_shr" {
  let x = 0xFF000000U
  inspect(x >> 8, content="16711680") // 0x00FF0000
  inspect(x >> 24, content="255") // 0x000000FF
}

test "UInt::op_shr/large_shift" {
  let x = 0xFF000000U
  inspect(x >> 32, content="4278190080") // Same as x >> 0 due to masking
}
>>
16).
(self : UInt) -> Byte

Converts an unsigned 32-bit integer to a byte by taking its least significant 8 bits. Any bits beyond the first 8 bits are truncated.

Parameters:

  • self : The unsigned 32-bit integer to be converted. Only the least significant 8 bits will be used.

Returns a byte containing the least significant 8 bits of the input integer.

Example:

test "UInt::to_byte" {
  let n = 258U // In binary: 100000010
  inspect(n.to_byte(), content="b'\\x02'") // Only keeps 00000010
  let big = 4294967295U // Maximum value of UInt
  inspect(big.to_byte(), content="b'\\xFF'") // Only keeps 11111111
}
to_byte
()
182 if
Int
dlen
(self : Int, other : Int) -> Bool

Compares two integers for equality.

Parameters:

  • self : The first integer to compare.
  • other : The second integer to compare.

Returns true if both integers have the same value, false otherwise.

Example:

test "Int::op_equal" {
  inspect(42 == 42, content="true")
  inspect(42 == -42, content="false")
}
==
4 {
183
FixedArray[Byte]
dst
(FixedArray[Byte], Int, Byte) -> Unit

Sets a value at the specified index in a fixed-size array. The original value at that index is overwritten.

Parameters:

  • array : The fixed-size array to modify.
  • index : The position in the array where the value will be set.
  • value : The new value to assign at the specified index.

Throws a runtime error if the index is out of bounds (less than 0 or greater than or equal to the length of the array).

Example:

test "FixedArray::op_set" {
  let arr = [1, 2, 3]
  arr[1] = 42
  inspect(arr, content="[1, 42, 3]")
}

test "panic FixedArray::op_set/out_of_bounds" {
  let arr = [1, 2, 3]
  arr[3] = 42 // Index out of bounds
}
[
dst_offset
(self : Int, other : Int) -> Int

Adds two 32-bit signed integers. Performs two's complement arithmetic, which means the operation will wrap around if the result exceeds the range of a 32-bit integer.

Parameters:

  • self : The first integer operand.
  • other : The second integer operand.

Returns a new integer that is the sum of the two operands. If the mathematical sum exceeds the range of a 32-bit integer (-2,147,483,648 to 2,147,483,647), the result wraps around according to two's complement rules.

Example:

test "Int::op_add" {
  inspect(42 + 1, content="43")
  inspect(2147483647 + 1, content="-2147483648") // Overflow wraps around to minimum value
}
+
2] =
FixedArray[Byte]
dbuf
[2]
184
FixedArray[Byte]
dbuf
[2] = b'\x00'
185 } 186 if
Int
dlen
(self_ : Int, other : Int) -> Bool
>=
3 {
187
FixedArray[Byte]
dst
(FixedArray[Byte], Int, Byte) -> Unit

Sets a value at the specified index in a fixed-size array. The original value at that index is overwritten.

Parameters:

  • array : The fixed-size array to modify.
  • index : The position in the array where the value will be set.
  • value : The new value to assign at the specified index.

Throws a runtime error if the index is out of bounds (less than 0 or greater than or equal to the length of the array).

Example:

test "FixedArray::op_set" {
  let arr = [1, 2, 3]
  arr[1] = 42
  inspect(arr, content="[1, 42, 3]")
}

test "panic FixedArray::op_set/out_of_bounds" {
  let arr = [1, 2, 3]
  arr[3] = 42 // Index out of bounds
}
[
dst_offset
(self : Int, other : Int) -> Int

Adds two 32-bit signed integers. Performs two's complement arithmetic, which means the operation will wrap around if the result exceeds the range of a 32-bit integer.

Parameters:

  • self : The first integer operand.
  • other : The second integer operand.

Returns a new integer that is the sum of the two operands. If the mathematical sum exceeds the range of a 32-bit integer (-2,147,483,648 to 2,147,483,647), the result wraps around according to two's complement rules.

Example:

test "Int::op_add" {
  inspect(42 + 1, content="43")
  inspect(2147483647 + 1, content="-2147483648") // Overflow wraps around to minimum value
}
+
1] =
FixedArray[Byte]
dbuf
[1]
188
FixedArray[Byte]
dbuf
[1] = b'\x00'
189 } 190 if
Int
dlen
(self_ : Int, other : Int) -> Bool
>=
2 {
191
FixedArray[Byte]
dst
(FixedArray[Byte], Int, Byte) -> Unit

Sets a value at the specified index in a fixed-size array. The original value at that index is overwritten.

Parameters:

  • array : The fixed-size array to modify.
  • index : The position in the array where the value will be set.
  • value : The new value to assign at the specified index.

Throws a runtime error if the index is out of bounds (less than 0 or greater than or equal to the length of the array).

Example:

test "FixedArray::op_set" {
  let arr = [1, 2, 3]
  arr[1] = 42
  inspect(arr, content="[1, 42, 3]")
}

test "panic FixedArray::op_set/out_of_bounds" {
  let arr = [1, 2, 3]
  arr[3] = 42 // Index out of bounds
}
[
dst_offset
(self : Int, other : Int) -> Int

Adds two 32-bit signed integers. Performs two's complement arithmetic, which means the operation will wrap around if the result exceeds the range of a 32-bit integer.

Parameters:

  • self : The first integer operand.
  • other : The second integer operand.

Returns a new integer that is the sum of the two operands. If the mathematical sum exceeds the range of a 32-bit integer (-2,147,483,648 to 2,147,483,647), the result wraps around according to two's complement rules.

Example:

test "Int::op_add" {
  inspect(42 + 1, content="43")
  inspect(2147483647 + 1, content="-2147483648") // Overflow wraps around to minimum value
}
+
0] =
FixedArray[Byte]
dbuf
[0]
192 } 193 return (
Int
si
,
Int
dlen
(self : Int, other : Int) -> Int

Performs subtraction between two 32-bit integers, following standard two's complement arithmetic rules. When the result overflows or underflows, it wraps around within the 32-bit integer range.

Parameters:

  • self : The minuend (the number being subtracted from).
  • other : The subtrahend (the number to subtract).

Returns the difference between self and other.

Example:

test "Int::op_sub" {
  let a = 42
  let b = 10
  inspect(a - b, content="32")
  let max = 2147483647 // Int maximum value
  inspect(max - -1, content="-2147483648") // Overflow case
}
-
1)
194} 195 196///| 197fn
(decode_map : FixedArray[Byte], dst : FixedArray[Byte], src : FixedArray[Byte], no_padding : Bool) -> Int!CorruptInputError
decode_buf
(
198
FixedArray[Byte]
decode_map
:
type FixedArray[A]
FixedArray
[
Byte
Byte
],
199
FixedArray[Byte]
dst
:
type FixedArray[A]
FixedArray
[
Byte
Byte
],
200
FixedArray[Byte]
src
:
type FixedArray[A]
FixedArray
[
Byte
Byte
],
201
Bool
no_padding
:
Bool
Bool
202) ->
Int
Int
!
type! CorruptInputError String

This package is based on the Go implementation found here: https://cs.opensource.google/go/go/+/master:src/encoding/base64/base64.go which has the copyright notice: Copyright 2009 The Go Authors. All rights reserved. Use of this source code is governed by a BSD-style license that can be found in the LICENSE file.

CorruptInputError
{
203 if
FixedArray[Byte]
src
.
(self : FixedArray[Byte]) -> Int

Returns the number of elements in a fixed-size array.

Parameters:

  • array : The fixed-size array whose length is to be determined.

Returns an integer representing the number of elements in the array.

Example:

test "FixedArray::length" {
  let arr = FixedArray::make(3, 42)
  inspect(arr.length(), content="3")
}
length
()
(self : Int, other : Int) -> Bool

Compares two integers for equality.

Parameters:

  • self : The first integer to compare.
  • other : The second integer to compare.

Returns true if both integers have the same value, false otherwise.

Example:

test "Int::op_equal" {
  inspect(42 == 42, content="true")
  inspect(42 == -42, content="false")
}
==
0 {
204 return 0 205 } 206 let
Byte
decode_pad_char
= if
Bool
no_padding
{ b'\xff' } else {
Byte
pad_char
}
207 // 208 let mut
Int
si
= 0
209 let mut
Int
n
= 0
210 for ;
FixedArray[Byte]
src
.
(self : FixedArray[Byte]) -> Int

Returns the number of elements in a fixed-size array.

Parameters:

  • array : The fixed-size array whose length is to be determined.

Returns an integer representing the number of elements in the array.

Example:

test "FixedArray::length" {
  let arr = FixedArray::make(3, 42)
  inspect(arr.length(), content="3")
}
length
()
(self : Int, other : Int) -> Int

Performs subtraction between two 32-bit integers, following standard two's complement arithmetic rules. When the result overflows or underflows, it wraps around within the 32-bit integer range.

Parameters:

  • self : The minuend (the number being subtracted from).
  • other : The subtrahend (the number to subtract).

Returns the difference between self and other.

Example:

test "Int::op_sub" {
  let a = 42
  let b = 10
  inspect(a - b, content="32")
  let max = 2147483647 // Int maximum value
  inspect(max - -1, content="-2147483648") // Overflow case
}
-
Int
si
(self_ : Int, other : Int) -> Bool
>=
4
(Bool, Bool) -> Bool
&&
FixedArray[Byte]
dst
.
(self : FixedArray[Byte]) -> Int

Returns the number of elements in a fixed-size array.

Parameters:

  • array : The fixed-size array whose length is to be determined.

Returns an integer representing the number of elements in the array.

Example:

test "FixedArray::length" {
  let arr = FixedArray::make(3, 42)
  inspect(arr.length(), content="3")
}
length
()
(self : Int, other : Int) -> Int

Performs subtraction between two 32-bit integers, following standard two's complement arithmetic rules. When the result overflows or underflows, it wraps around within the 32-bit integer range.

Parameters:

  • self : The minuend (the number being subtracted from).
  • other : The subtrahend (the number to subtract).

Returns the difference between self and other.

Example:

test "Int::op_sub" {
  let a = 42
  let b = 10
  inspect(a - b, content="32")
  let max = 2147483647 // Int maximum value
  inspect(max - -1, content="-2147483648") // Overflow case
}
-
Int
n
(self_ : Int, other : Int) -> Bool
>=
4; {
211 let (
UInt
dn
,
Bool
ok
) =
(n1 : Byte, n2 : Byte, n3 : Byte, n4 : Byte) -> (UInt, Bool)
assemble32
(
212
FixedArray[Byte]
decode_map
(FixedArray[Byte], Int) -> Byte

Retrieves an element at the specified index from a fixed-size array. This function implements the array indexing operator [].

Parameters:

  • array : The fixed-size array to access.
  • index : The position in the array from which to retrieve the element.

Returns the element at the specified index.

Throws a runtime error if the index is out of bounds (negative or greater than or equal to the length of the array).

Example:

test "FixedArray::op_get" {
  let arr = FixedArray::make(3, 42)
  inspect(arr[1], content="42")
}

test "panic FixedArray::op_get/out_of_bounds" {
  let arr = FixedArray::make(3, 0)
  ignore(arr[3]) // Index out of bounds
}
[
FixedArray[Byte]
src
(FixedArray[Byte], Int) -> Byte

Retrieves an element at the specified index from a fixed-size array. This function implements the array indexing operator [].

Parameters:

  • array : The fixed-size array to access.
  • index : The position in the array from which to retrieve the element.

Returns the element at the specified index.

Throws a runtime error if the index is out of bounds (negative or greater than or equal to the length of the array).

Example:

test "FixedArray::op_get" {
  let arr = FixedArray::make(3, 42)
  inspect(arr[1], content="42")
}

test "panic FixedArray::op_get/out_of_bounds" {
  let arr = FixedArray::make(3, 0)
  ignore(arr[3]) // Index out of bounds
}
[
si
(self : Int, other : Int) -> Int

Adds two 32-bit signed integers. Performs two's complement arithmetic, which means the operation will wrap around if the result exceeds the range of a 32-bit integer.

Parameters:

  • self : The first integer operand.
  • other : The second integer operand.

Returns a new integer that is the sum of the two operands. If the mathematical sum exceeds the range of a 32-bit integer (-2,147,483,648 to 2,147,483,647), the result wraps around according to two's complement rules.

Example:

test "Int::op_add" {
  inspect(42 + 1, content="43")
  inspect(2147483647 + 1, content="-2147483648") // Overflow wraps around to minimum value
}
+
0].
(self : Byte) -> Int

Converts a byte value to a 32-bit signed integer. The resulting integer will have the same binary representation as the byte value, preserving the numerical value in the range [0, 255].

Parameters:

  • byte : The byte value to be converted to an integer.

Returns a 32-bit signed integer representing the same numerical value as the input byte.

Example:

test "Byte::to_int" {
  let b = b'\xFF' // byte with value 255
  inspect(b.to_int(), content="255")
  let zero = b'\x00'
  inspect(zero.to_int(), content="0")
}
to_int
()],
213
FixedArray[Byte]
decode_map
(FixedArray[Byte], Int) -> Byte

Retrieves an element at the specified index from a fixed-size array. This function implements the array indexing operator [].

Parameters:

  • array : The fixed-size array to access.
  • index : The position in the array from which to retrieve the element.

Returns the element at the specified index.

Throws a runtime error if the index is out of bounds (negative or greater than or equal to the length of the array).

Example:

test "FixedArray::op_get" {
  let arr = FixedArray::make(3, 42)
  inspect(arr[1], content="42")
}

test "panic FixedArray::op_get/out_of_bounds" {
  let arr = FixedArray::make(3, 0)
  ignore(arr[3]) // Index out of bounds
}
[
FixedArray[Byte]
src
(FixedArray[Byte], Int) -> Byte

Retrieves an element at the specified index from a fixed-size array. This function implements the array indexing operator [].

Parameters:

  • array : The fixed-size array to access.
  • index : The position in the array from which to retrieve the element.

Returns the element at the specified index.

Throws a runtime error if the index is out of bounds (negative or greater than or equal to the length of the array).

Example:

test "FixedArray::op_get" {
  let arr = FixedArray::make(3, 42)
  inspect(arr[1], content="42")
}

test "panic FixedArray::op_get/out_of_bounds" {
  let arr = FixedArray::make(3, 0)
  ignore(arr[3]) // Index out of bounds
}
[
si
(self : Int, other : Int) -> Int

Adds two 32-bit signed integers. Performs two's complement arithmetic, which means the operation will wrap around if the result exceeds the range of a 32-bit integer.

Parameters:

  • self : The first integer operand.
  • other : The second integer operand.

Returns a new integer that is the sum of the two operands. If the mathematical sum exceeds the range of a 32-bit integer (-2,147,483,648 to 2,147,483,647), the result wraps around according to two's complement rules.

Example:

test "Int::op_add" {
  inspect(42 + 1, content="43")
  inspect(2147483647 + 1, content="-2147483648") // Overflow wraps around to minimum value
}
+
1].
(self : Byte) -> Int

Converts a byte value to a 32-bit signed integer. The resulting integer will have the same binary representation as the byte value, preserving the numerical value in the range [0, 255].

Parameters:

  • byte : The byte value to be converted to an integer.

Returns a 32-bit signed integer representing the same numerical value as the input byte.

Example:

test "Byte::to_int" {
  let b = b'\xFF' // byte with value 255
  inspect(b.to_int(), content="255")
  let zero = b'\x00'
  inspect(zero.to_int(), content="0")
}
to_int
()],
214
FixedArray[Byte]
decode_map
(FixedArray[Byte], Int) -> Byte

Retrieves an element at the specified index from a fixed-size array. This function implements the array indexing operator [].

Parameters:

  • array : The fixed-size array to access.
  • index : The position in the array from which to retrieve the element.

Returns the element at the specified index.

Throws a runtime error if the index is out of bounds (negative or greater than or equal to the length of the array).

Example:

test "FixedArray::op_get" {
  let arr = FixedArray::make(3, 42)
  inspect(arr[1], content="42")
}

test "panic FixedArray::op_get/out_of_bounds" {
  let arr = FixedArray::make(3, 0)
  ignore(arr[3]) // Index out of bounds
}
[
FixedArray[Byte]
src
(FixedArray[Byte], Int) -> Byte

Retrieves an element at the specified index from a fixed-size array. This function implements the array indexing operator [].

Parameters:

  • array : The fixed-size array to access.
  • index : The position in the array from which to retrieve the element.

Returns the element at the specified index.

Throws a runtime error if the index is out of bounds (negative or greater than or equal to the length of the array).

Example:

test "FixedArray::op_get" {
  let arr = FixedArray::make(3, 42)
  inspect(arr[1], content="42")
}

test "panic FixedArray::op_get/out_of_bounds" {
  let arr = FixedArray::make(3, 0)
  ignore(arr[3]) // Index out of bounds
}
[
si
(self : Int, other : Int) -> Int

Adds two 32-bit signed integers. Performs two's complement arithmetic, which means the operation will wrap around if the result exceeds the range of a 32-bit integer.

Parameters:

  • self : The first integer operand.
  • other : The second integer operand.

Returns a new integer that is the sum of the two operands. If the mathematical sum exceeds the range of a 32-bit integer (-2,147,483,648 to 2,147,483,647), the result wraps around according to two's complement rules.

Example:

test "Int::op_add" {
  inspect(42 + 1, content="43")
  inspect(2147483647 + 1, content="-2147483648") // Overflow wraps around to minimum value
}
+
2].
(self : Byte) -> Int

Converts a byte value to a 32-bit signed integer. The resulting integer will have the same binary representation as the byte value, preserving the numerical value in the range [0, 255].

Parameters:

  • byte : The byte value to be converted to an integer.

Returns a 32-bit signed integer representing the same numerical value as the input byte.

Example:

test "Byte::to_int" {
  let b = b'\xFF' // byte with value 255
  inspect(b.to_int(), content="255")
  let zero = b'\x00'
  inspect(zero.to_int(), content="0")
}
to_int
()],
215
FixedArray[Byte]
decode_map
(FixedArray[Byte], Int) -> Byte

Retrieves an element at the specified index from a fixed-size array. This function implements the array indexing operator [].

Parameters:

  • array : The fixed-size array to access.
  • index : The position in the array from which to retrieve the element.

Returns the element at the specified index.

Throws a runtime error if the index is out of bounds (negative or greater than or equal to the length of the array).

Example:

test "FixedArray::op_get" {
  let arr = FixedArray::make(3, 42)
  inspect(arr[1], content="42")
}

test "panic FixedArray::op_get/out_of_bounds" {
  let arr = FixedArray::make(3, 0)
  ignore(arr[3]) // Index out of bounds
}
[
FixedArray[Byte]
src
(FixedArray[Byte], Int) -> Byte

Retrieves an element at the specified index from a fixed-size array. This function implements the array indexing operator [].

Parameters:

  • array : The fixed-size array to access.
  • index : The position in the array from which to retrieve the element.

Returns the element at the specified index.

Throws a runtime error if the index is out of bounds (negative or greater than or equal to the length of the array).

Example:

test "FixedArray::op_get" {
  let arr = FixedArray::make(3, 42)
  inspect(arr[1], content="42")
}

test "panic FixedArray::op_get/out_of_bounds" {
  let arr = FixedArray::make(3, 0)
  ignore(arr[3]) // Index out of bounds
}
[
si
(self : Int, other : Int) -> Int

Adds two 32-bit signed integers. Performs two's complement arithmetic, which means the operation will wrap around if the result exceeds the range of a 32-bit integer.

Parameters:

  • self : The first integer operand.
  • other : The second integer operand.

Returns a new integer that is the sum of the two operands. If the mathematical sum exceeds the range of a 32-bit integer (-2,147,483,648 to 2,147,483,647), the result wraps around according to two's complement rules.

Example:

test "Int::op_add" {
  inspect(42 + 1, content="43")
  inspect(2147483647 + 1, content="-2147483648") // Overflow wraps around to minimum value
}
+
3].
(self : Byte) -> Int

Converts a byte value to a 32-bit signed integer. The resulting integer will have the same binary representation as the byte value, preserving the numerical value in the range [0, 255].

Parameters:

  • byte : The byte value to be converted to an integer.

Returns a 32-bit signed integer representing the same numerical value as the input byte.

Example:

test "Byte::to_int" {
  let b = b'\xFF' // byte with value 255
  inspect(b.to_int(), content="255")
  let zero = b'\x00'
  inspect(zero.to_int(), content="0")
}
to_int
()],
216 ) 217 if
Bool
ok
{
218
(b : FixedArray[Byte], offset : Int, value : UInt) -> Unit
be_put_uint32
(
FixedArray[Byte]
dst
,
Int
n
,
UInt
dn
)
219
Int
n
(self : Int, other : Int) -> Int

Adds two 32-bit signed integers. Performs two's complement arithmetic, which means the operation will wrap around if the result exceeds the range of a 32-bit integer.

Parameters:

  • self : The first integer operand.
  • other : The second integer operand.

Returns a new integer that is the sum of the two operands. If the mathematical sum exceeds the range of a 32-bit integer (-2,147,483,648 to 2,147,483,647), the result wraps around according to two's complement rules.

Example:

test "Int::op_add" {
  inspect(42 + 1, content="43")
  inspect(2147483647 + 1, content="-2147483648") // Overflow wraps around to minimum value
}
+=
3
220
Int
si
(self : Int, other : Int) -> Int

Adds two 32-bit signed integers. Performs two's complement arithmetic, which means the operation will wrap around if the result exceeds the range of a 32-bit integer.

Parameters:

  • self : The first integer operand.
  • other : The second integer operand.

Returns a new integer that is the sum of the two operands. If the mathematical sum exceeds the range of a 32-bit integer (-2,147,483,648 to 2,147,483,647), the result wraps around according to two's complement rules.

Example:

test "Int::op_add" {
  inspect(42 + 1, content="43")
  inspect(2147483647 + 1, content="-2147483648") // Overflow wraps around to minimum value
}
+=
4
221 } else { 222 let
(Int, Int)
pair
=
(decode_map : FixedArray[Byte], dst : FixedArray[Byte], dst_offset : Int, src : FixedArray[Byte], si : Int, decode_pad_char : Byte, no_padding : Bool) -> (Int, Int)!CorruptInputError
decode_quantum
!(
223
FixedArray[Byte]
decode_map
,
FixedArray[Byte]
dst
,
Int
n
,
FixedArray[Byte]
src
,
Int
si
,
Byte
decode_pad_char
,
Bool
no_padding
,
224 ) 225
Int
si
=
(Int, Int)
pair
.
Int
0
226 let
Int
ninc
=
(Int, Int)
pair
.
Int
1
227
Int
n
(self : Int, other : Int) -> Int

Adds two 32-bit signed integers. Performs two's complement arithmetic, which means the operation will wrap around if the result exceeds the range of a 32-bit integer.

Parameters:

  • self : The first integer operand.
  • other : The second integer operand.

Returns a new integer that is the sum of the two operands. If the mathematical sum exceeds the range of a 32-bit integer (-2,147,483,648 to 2,147,483,647), the result wraps around according to two's complement rules.

Example:

test "Int::op_add" {
  inspect(42 + 1, content="43")
  inspect(2147483647 + 1, content="-2147483648") // Overflow wraps around to minimum value
}
+=
Int
ninc
228 } 229 } 230 for ;
Int
si
(self_ : Int, other : Int) -> Bool
<
FixedArray[Byte]
src
.
(self : FixedArray[Byte]) -> Int

Returns the number of elements in a fixed-size array.

Parameters:

  • array : The fixed-size array whose length is to be determined.

Returns an integer representing the number of elements in the array.

Example:

test "FixedArray::length" {
  let arr = FixedArray::make(3, 42)
  inspect(arr.length(), content="3")
}
length
(); {
231 let
(Int, Int)
pair
=
(decode_map : FixedArray[Byte], dst : FixedArray[Byte], dst_offset : Int, src : FixedArray[Byte], si : Int, decode_pad_char : Byte, no_padding : Bool) -> (Int, Int)!CorruptInputError
decode_quantum
!(
232
FixedArray[Byte]
decode_map
,
FixedArray[Byte]
dst
,
Int
n
,
FixedArray[Byte]
src
,
Int
si
,
Byte
decode_pad_char
,
Bool
no_padding
,
233 ) 234
Int
si
=
(Int, Int)
pair
.
Int
0
235 let
Int
ninc
=
(Int, Int)
pair
.
Int
1
236
Int
n
(self : Int, other : Int) -> Int

Adds two 32-bit signed integers. Performs two's complement arithmetic, which means the operation will wrap around if the result exceeds the range of a 32-bit integer.

Parameters:

  • self : The first integer operand.
  • other : The second integer operand.

Returns a new integer that is the sum of the two operands. If the mathematical sum exceeds the range of a 32-bit integer (-2,147,483,648 to 2,147,483,647), the result wraps around according to two's complement rules.

Example:

test "Int::op_add" {
  inspect(42 + 1, content="43")
  inspect(2147483647 + 1, content="-2147483648") // Overflow wraps around to minimum value
}
+=
Int
ninc
237 } 238
Int
n
239} 240 241///| 242fn
(b : FixedArray[Byte], offset : Int, value : UInt) -> Unit
be_put_uint32
(
FixedArray[Byte]
b
:
type FixedArray[A]
FixedArray
[
Byte
Byte
],
Int
offset
:
Int
Int
,
UInt
value
:
UInt
UInt
) ->
Unit
Unit
{
243
FixedArray[Byte]
b
(FixedArray[Byte], Int, Byte) -> Unit

Sets a value at the specified index in a fixed-size array. The original value at that index is overwritten.

Parameters:

  • array : The fixed-size array to modify.
  • index : The position in the array where the value will be set.
  • value : The new value to assign at the specified index.

Throws a runtime error if the index is out of bounds (less than 0 or greater than or equal to the length of the array).

Example:

test "FixedArray::op_set" {
  let arr = [1, 2, 3]
  arr[1] = 42
  inspect(arr, content="[1, 42, 3]")
}

test "panic FixedArray::op_set/out_of_bounds" {
  let arr = [1, 2, 3]
  arr[3] = 42 // Index out of bounds
}
[
offset
(self : Int, other : Int) -> Int

Adds two 32-bit signed integers. Performs two's complement arithmetic, which means the operation will wrap around if the result exceeds the range of a 32-bit integer.

Parameters:

  • self : The first integer operand.
  • other : The second integer operand.

Returns a new integer that is the sum of the two operands. If the mathematical sum exceeds the range of a 32-bit integer (-2,147,483,648 to 2,147,483,647), the result wraps around according to two's complement rules.

Example:

test "Int::op_add" {
  inspect(42 + 1, content="43")
  inspect(2147483647 + 1, content="-2147483648") // Overflow wraps around to minimum value
}
+
3] = (
UInt
value
(UInt, UInt) -> UInt
&
0xff).
(self : UInt) -> Byte

Converts an unsigned 32-bit integer to a byte by taking its least significant 8 bits. Any bits beyond the first 8 bits are truncated.

Parameters:

  • self : The unsigned 32-bit integer to be converted. Only the least significant 8 bits will be used.

Returns a byte containing the least significant 8 bits of the input integer.

Example:

test "UInt::to_byte" {
  let n = 258U // In binary: 100000010
  inspect(n.to_byte(), content="b'\\x02'") // Only keeps 00000010
  let big = 4294967295U // Maximum value of UInt
  inspect(big.to_byte(), content="b'\\xFF'") // Only keeps 11111111
}
to_byte
()
244
FixedArray[Byte]
b
(FixedArray[Byte], Int, Byte) -> Unit

Sets a value at the specified index in a fixed-size array. The original value at that index is overwritten.

Parameters:

  • array : The fixed-size array to modify.
  • index : The position in the array where the value will be set.
  • value : The new value to assign at the specified index.

Throws a runtime error if the index is out of bounds (less than 0 or greater than or equal to the length of the array).

Example:

test "FixedArray::op_set" {
  let arr = [1, 2, 3]
  arr[1] = 42
  inspect(arr, content="[1, 42, 3]")
}

test "panic FixedArray::op_set/out_of_bounds" {
  let arr = [1, 2, 3]
  arr[3] = 42 // Index out of bounds
}
[
offset
(self : Int, other : Int) -> Int

Adds two 32-bit signed integers. Performs two's complement arithmetic, which means the operation will wrap around if the result exceeds the range of a 32-bit integer.

Parameters:

  • self : The first integer operand.
  • other : The second integer operand.

Returns a new integer that is the sum of the two operands. If the mathematical sum exceeds the range of a 32-bit integer (-2,147,483,648 to 2,147,483,647), the result wraps around according to two's complement rules.

Example:

test "Int::op_add" {
  inspect(42 + 1, content="43")
  inspect(2147483647 + 1, content="-2147483648") // Overflow wraps around to minimum value
}
+
2] = ((
UInt
value
(self : UInt, shift : Int) -> UInt

Performs a logical right shift operation on an unsigned 32-bit integer. The operation shifts all bits to the right by a specified number of positions, filling the leftmost positions with zeros.

Parameters:

  • self : The unsigned 32-bit integer to be shifted.
  • shift : The number of positions to shift right. If this value is negative, the behavior is undefined. Values larger than 31 are masked with & 31.

Returns a new unsigned 32-bit integer containing the result of the right shift operation.

Example:

test "UInt::op_shr" {
  let x = 0xFF000000U
  inspect(x >> 8, content="16711680") // 0x00FF0000
  inspect(x >> 24, content="255") // 0x000000FF
}

test "UInt::op_shr/large_shift" {
  let x = 0xFF000000U
  inspect(x >> 32, content="4278190080") // Same as x >> 0 due to masking
}
>>
8)
(UInt, UInt) -> UInt
&
0xff).
(self : UInt) -> Byte

Converts an unsigned 32-bit integer to a byte by taking its least significant 8 bits. Any bits beyond the first 8 bits are truncated.

Parameters:

  • self : The unsigned 32-bit integer to be converted. Only the least significant 8 bits will be used.

Returns a byte containing the least significant 8 bits of the input integer.

Example:

test "UInt::to_byte" {
  let n = 258U // In binary: 100000010
  inspect(n.to_byte(), content="b'\\x02'") // Only keeps 00000010
  let big = 4294967295U // Maximum value of UInt
  inspect(big.to_byte(), content="b'\\xFF'") // Only keeps 11111111
}
to_byte
()
245
FixedArray[Byte]
b
(FixedArray[Byte], Int, Byte) -> Unit

Sets a value at the specified index in a fixed-size array. The original value at that index is overwritten.

Parameters:

  • array : The fixed-size array to modify.
  • index : The position in the array where the value will be set.
  • value : The new value to assign at the specified index.

Throws a runtime error if the index is out of bounds (less than 0 or greater than or equal to the length of the array).

Example:

test "FixedArray::op_set" {
  let arr = [1, 2, 3]
  arr[1] = 42
  inspect(arr, content="[1, 42, 3]")
}

test "panic FixedArray::op_set/out_of_bounds" {
  let arr = [1, 2, 3]
  arr[3] = 42 // Index out of bounds
}
[
offset
(self : Int, other : Int) -> Int

Adds two 32-bit signed integers. Performs two's complement arithmetic, which means the operation will wrap around if the result exceeds the range of a 32-bit integer.

Parameters:

  • self : The first integer operand.
  • other : The second integer operand.

Returns a new integer that is the sum of the two operands. If the mathematical sum exceeds the range of a 32-bit integer (-2,147,483,648 to 2,147,483,647), the result wraps around according to two's complement rules.

Example:

test "Int::op_add" {
  inspect(42 + 1, content="43")
  inspect(2147483647 + 1, content="-2147483648") // Overflow wraps around to minimum value
}
+
1] = ((
UInt
value
(self : UInt, shift : Int) -> UInt

Performs a logical right shift operation on an unsigned 32-bit integer. The operation shifts all bits to the right by a specified number of positions, filling the leftmost positions with zeros.

Parameters:

  • self : The unsigned 32-bit integer to be shifted.
  • shift : The number of positions to shift right. If this value is negative, the behavior is undefined. Values larger than 31 are masked with & 31.

Returns a new unsigned 32-bit integer containing the result of the right shift operation.

Example:

test "UInt::op_shr" {
  let x = 0xFF000000U
  inspect(x >> 8, content="16711680") // 0x00FF0000
  inspect(x >> 24, content="255") // 0x000000FF
}

test "UInt::op_shr/large_shift" {
  let x = 0xFF000000U
  inspect(x >> 32, content="4278190080") // Same as x >> 0 due to masking
}
>>
16)
(UInt, UInt) -> UInt
&
0xff).
(self : UInt) -> Byte

Converts an unsigned 32-bit integer to a byte by taking its least significant 8 bits. Any bits beyond the first 8 bits are truncated.

Parameters:

  • self : The unsigned 32-bit integer to be converted. Only the least significant 8 bits will be used.

Returns a byte containing the least significant 8 bits of the input integer.

Example:

test "UInt::to_byte" {
  let n = 258U // In binary: 100000010
  inspect(n.to_byte(), content="b'\\x02'") // Only keeps 00000010
  let big = 4294967295U // Maximum value of UInt
  inspect(big.to_byte(), content="b'\\xFF'") // Only keeps 11111111
}
to_byte
()
246
FixedArray[Byte]
b
(FixedArray[Byte], Int, Byte) -> Unit

Sets a value at the specified index in a fixed-size array. The original value at that index is overwritten.

Parameters:

  • array : The fixed-size array to modify.
  • index : The position in the array where the value will be set.
  • value : The new value to assign at the specified index.

Throws a runtime error if the index is out of bounds (less than 0 or greater than or equal to the length of the array).

Example:

test "FixedArray::op_set" {
  let arr = [1, 2, 3]
  arr[1] = 42
  inspect(arr, content="[1, 42, 3]")
}

test "panic FixedArray::op_set/out_of_bounds" {
  let arr = [1, 2, 3]
  arr[3] = 42 // Index out of bounds
}
[
offset] = ((
UInt
value
(self : UInt, shift : Int) -> UInt

Performs a logical right shift operation on an unsigned 32-bit integer. The operation shifts all bits to the right by a specified number of positions, filling the leftmost positions with zeros.

Parameters:

  • self : The unsigned 32-bit integer to be shifted.
  • shift : The number of positions to shift right. If this value is negative, the behavior is undefined. Values larger than 31 are masked with & 31.

Returns a new unsigned 32-bit integer containing the result of the right shift operation.

Example:

test "UInt::op_shr" {
  let x = 0xFF000000U
  inspect(x >> 8, content="16711680") // 0x00FF0000
  inspect(x >> 24, content="255") // 0x000000FF
}

test "UInt::op_shr/large_shift" {
  let x = 0xFF000000U
  inspect(x >> 32, content="4278190080") // Same as x >> 0 due to masking
}
>>
24)
(UInt, UInt) -> UInt
&
0xff).
(self : UInt) -> Byte

Converts an unsigned 32-bit integer to a byte by taking its least significant 8 bits. Any bits beyond the first 8 bits are truncated.

Parameters:

  • self : The unsigned 32-bit integer to be converted. Only the least significant 8 bits will be used.

Returns a byte containing the least significant 8 bits of the input integer.

Example:

test "UInt::to_byte" {
  let n = 258U // In binary: 100000010
  inspect(n.to_byte(), content="b'\\x02'") // Only keeps 00000010
  let big = 4294967295U // Maximum value of UInt
  inspect(big.to_byte(), content="b'\\xFF'") // Only keeps 11111111
}
to_byte
()
247} 248 249// assemble32 assembles 4 base64 digits into 3 bytes. 250// Each digit comes from the decode map, and will be 0xff 251// if it came from an invalid character. 252///| 253fn
(n1 : Byte, n2 : Byte, n3 : Byte, n4 : Byte) -> (UInt, Bool)
assemble32
(
Byte
n1
:
Byte
Byte
,
Byte
n2
:
Byte
Byte
,
Byte
n3
:
Byte
Byte
,
Byte
n4
:
Byte
Byte
) -> (
UInt
UInt
,
Bool
Bool
) {
254 // Check that all the digits are valid. If any of them was 0xff, their 255 // bitwise OR will be 0xff. 256 if (
Byte
n1
(self : Byte, that : Byte) -> Byte

Performs a bitwise OR operation between two Byte values.

Parameters:

  • self : The first Byte value.
  • that : The second Byte value.

Returns a new Byte value resulting from the bitwise OR operation.

|
(
Byte
n2
(self : Byte, that : Byte) -> Byte

Performs a bitwise OR operation between two Byte values.

Parameters:

  • self : The first Byte value.
  • that : The second Byte value.

Returns a new Byte value resulting from the bitwise OR operation.

|
(
Byte
n3
(self : Byte, that : Byte) -> Byte

Performs a bitwise OR operation between two Byte values.

Parameters:

  • self : The first Byte value.
  • that : The second Byte value.

Returns a new Byte value resulting from the bitwise OR operation.

|
Byte
n4
)))
(self : Byte, that : Byte) -> Bool

Compares two Byte values for equality.

Parameters:

  • self : The first Byte value to compare.
  • that : The second Byte value to compare.

Returns true if the two Byte values are equal, otherwise false.

==
b'\xff' {
257 return (0, false) 258 } 259 ( 260 (
Byte
n1
.
(self : Byte) -> UInt

Converts a Byte to a UInt.

Parameters:

  • byte : The Byte value to be converted.

Returns the UInt representation of the Byte.

to_uint
()
(self : UInt, shift : Int) -> UInt

Performs a left shift operation on an unsigned 32-bit integer. Each bit in the integer is shifted left by the specified number of positions, and zeros are filled in from the right.

Parameters:

  • self : The unsigned 32-bit integer to be shifted.
  • shift : The number of positions to shift. Only the least significant 5 bits are used, effectively making the shift count always between 0 and 31.

Returns a new unsigned 32-bit integer that is the result of shifting self left by shift positions.

Example:

test "UInt::op_shl" {
  let x = 1U
  inspect(x << 3, content="8") // Binary: 1 -> 1000
  let y = 0xFFFFFFFFU
  inspect(y << 16, content="4294901760") // All bits after position 16 are discarded
}
<<
26)
(UInt, UInt) -> UInt
|
261 ((
Byte
n2
.
(self : Byte) -> UInt

Converts a Byte to a UInt.

Parameters:

  • byte : The Byte value to be converted.

Returns the UInt representation of the Byte.

to_uint
()
(self : UInt, shift : Int) -> UInt

Performs a left shift operation on an unsigned 32-bit integer. Each bit in the integer is shifted left by the specified number of positions, and zeros are filled in from the right.

Parameters:

  • self : The unsigned 32-bit integer to be shifted.
  • shift : The number of positions to shift. Only the least significant 5 bits are used, effectively making the shift count always between 0 and 31.

Returns a new unsigned 32-bit integer that is the result of shifting self left by shift positions.

Example:

test "UInt::op_shl" {
  let x = 1U
  inspect(x << 3, content="8") // Binary: 1 -> 1000
  let y = 0xFFFFFFFFU
  inspect(y << 16, content="4294901760") // All bits after position 16 are discarded
}
<<
20)
(UInt, UInt) -> UInt
|
((
Byte
n3
.
(self : Byte) -> UInt

Converts a Byte to a UInt.

Parameters:

  • byte : The Byte value to be converted.

Returns the UInt representation of the Byte.

to_uint
()
(self : UInt, shift : Int) -> UInt

Performs a left shift operation on an unsigned 32-bit integer. Each bit in the integer is shifted left by the specified number of positions, and zeros are filled in from the right.

Parameters:

  • self : The unsigned 32-bit integer to be shifted.
  • shift : The number of positions to shift. Only the least significant 5 bits are used, effectively making the shift count always between 0 and 31.

Returns a new unsigned 32-bit integer that is the result of shifting self left by shift positions.

Example:

test "UInt::op_shl" {
  let x = 1U
  inspect(x << 3, content="8") // Binary: 1 -> 1000
  let y = 0xFFFFFFFFU
  inspect(y << 16, content="4294901760") // All bits after position 16 are discarded
}
<<
14)
(UInt, UInt) -> UInt
|
(
Byte
n4
.
(self : Byte) -> UInt

Converts a Byte to a UInt.

Parameters:

  • byte : The Byte value to be converted.

Returns the UInt representation of the Byte.

to_uint
()
(self : UInt, shift : Int) -> UInt

Performs a left shift operation on an unsigned 32-bit integer. Each bit in the integer is shifted left by the specified number of positions, and zeros are filled in from the right.

Parameters:

  • self : The unsigned 32-bit integer to be shifted.
  • shift : The number of positions to shift. Only the least significant 5 bits are used, effectively making the shift count always between 0 and 31.

Returns a new unsigned 32-bit integer that is the result of shifting self left by shift positions.

Example:

test "UInt::op_shl" {
  let x = 1U
  inspect(x << 3, content="8") // Binary: 1 -> 1000
  let y = 0xFFFFFFFFU
  inspect(y << 16, content="4294901760") // All bits after position 16 are discarded
}
<<
8))),
262 true, 263 ) 264} 265 266///| 267fn
(n : Int, no_padding : Bool) -> Int
decoded_len
(
Int
n
:
Int
Int
,
Bool
no_padding
:
Bool
Bool
) ->
Int
Int
{
268 if
Bool
no_padding
{
269 return
Int
n
(self : Int, other : Int) -> Int

Performs integer division between two 32-bit integers. The result is truncated towards zero (rounds down for positive numbers and up for negative numbers).

Parameters:

  • dividend : The first integer operand to be divided.
  • divisor : The second integer operand that divides the dividend.

Returns the quotient of the division operation.

Throws a panic if divisor is zero.

Example:

test "Int::op_div" {
  inspect(10 / 3, content="3") // truncates towards zero
  inspect(-10 / 3, content="-3")
  inspect(10 / -3, content="-3")
}

test "panic Int::op_div/division_by_zero" {
  ignore(42 / 0) // Panics with division by zero
}
/
4
(self : Int, other : Int) -> Int

Multiplies two 32-bit integers. This is the implementation of the * operator for Int.

Parameters:

  • self : The first integer operand.
  • other : The second integer operand.

Returns the product of the two integers. If the result overflows the range of Int, it wraps around according to two's complement arithmetic.

Example:

test "Int::op_mul" {
  inspect(42 * 2, content="84")
  inspect(-10 * 3, content="-30")
  let max = 2147483647 // Int.max_value
  inspect(max * 2, content="-2") // Overflow wraps around
}
*
3
(self : Int, other : Int) -> Int

Adds two 32-bit signed integers. Performs two's complement arithmetic, which means the operation will wrap around if the result exceeds the range of a 32-bit integer.

Parameters:

  • self : The first integer operand.
  • other : The second integer operand.

Returns a new integer that is the sum of the two operands. If the mathematical sum exceeds the range of a 32-bit integer (-2,147,483,648 to 2,147,483,647), the result wraps around according to two's complement rules.

Example:

test "Int::op_add" {
  inspect(42 + 1, content="43")
  inspect(2147483647 + 1, content="-2147483648") // Overflow wraps around to minimum value
}
+
Int
n
(self : Int, other : Int) -> Int

Calculates the remainder of dividing one integer by another. The result follows the formula dividend - (dividend / divisor) * divisor, maintaining the same sign as the dividend.

Parameters:

  • self : The dividend (the number being divided).
  • other : The divisor (the number to divide by).

Returns the remainder of the division. If other is 0, the behavior is undefined.

Example:

test "Int::op_mod" {
  inspect(7 % 3, content="1")
  inspect(-7 % 3, content="-1")
  inspect(7 % -3, content="1")
}

test "panic Int::op_mod/division_by_zero" {
  ignore(7 % 0) // Panics with division by zero
}
%
4
(self : Int, other : Int) -> Int

Multiplies two 32-bit integers. This is the implementation of the * operator for Int.

Parameters:

  • self : The first integer operand.
  • other : The second integer operand.

Returns the product of the two integers. If the result overflows the range of Int, it wraps around according to two's complement arithmetic.

Example:

test "Int::op_mul" {
  inspect(42 * 2, content="84")
  inspect(-10 * 3, content="-30")
  let max = 2147483647 // Int.max_value
  inspect(max * 2, content="-2") // Overflow wraps around
}
*
6
(self : Int, other : Int) -> Int

Performs integer division between two 32-bit integers. The result is truncated towards zero (rounds down for positive numbers and up for negative numbers).

Parameters:

  • dividend : The first integer operand to be divided.
  • divisor : The second integer operand that divides the dividend.

Returns the quotient of the division operation.

Throws a panic if divisor is zero.

Example:

test "Int::op_div" {
  inspect(10 / 3, content="3") // truncates towards zero
  inspect(-10 / 3, content="-3")
  inspect(10 / -3, content="-3")
}

test "panic Int::op_div/division_by_zero" {
  ignore(42 / 0) // Panics with division by zero
}
/
8
270 } 271
Int
n
(self : Int, other : Int) -> Int

Performs integer division between two 32-bit integers. The result is truncated towards zero (rounds down for positive numbers and up for negative numbers).

Parameters:

  • dividend : The first integer operand to be divided.
  • divisor : The second integer operand that divides the dividend.

Returns the quotient of the division operation.

Throws a panic if divisor is zero.

Example:

test "Int::op_div" {
  inspect(10 / 3, content="3") // truncates towards zero
  inspect(-10 / 3, content="-3")
  inspect(10 / -3, content="-3")
}

test "panic Int::op_div/division_by_zero" {
  ignore(42 / 0) // Panics with division by zero
}
/
4
(self : Int, other : Int) -> Int

Multiplies two 32-bit integers. This is the implementation of the * operator for Int.

Parameters:

  • self : The first integer operand.
  • other : The second integer operand.

Returns the product of the two integers. If the result overflows the range of Int, it wraps around according to two's complement arithmetic.

Example:

test "Int::op_mul" {
  inspect(42 * 2, content="84")
  inspect(-10 * 3, content="-30")
  let max = 2147483647 // Int.max_value
  inspect(max * 2, content="-2") // Overflow wraps around
}
*
3
272} 273 274///| 275let
FixedArray[Byte]
std_decode_map
:
type FixedArray[A]
FixedArray
[
Byte
Byte
] = [
276 b'\xff', b'\xff', b'\xff', b'\xff', b'\xff', b'\xff', b'\xff', b'\xff', b'\xff', 277 b'\xff', b'\xff', b'\xff', b'\xff', b'\xff', b'\xff', b'\xff', b'\xff', b'\xff', 278 b'\xff', b'\xff', b'\xff', b'\xff', b'\xff', b'\xff', b'\xff', b'\xff', b'\xff', 279 b'\xff', b'\xff', b'\xff', b'\xff', b'\xff', b'\xff', b'\xff', b'\xff', b'\xff', 280 b'\xff', b'\xff', b'\xff', b'\xff', b'\xff', b'\xff', b'\xff', b'\x3e', b'\xff', 281 b'\xff', b'\xff', b'\x3f', b'\x34', b'\x35', b'\x36', b'\x37', b'\x38', b'\x39', 282 b'\x3a', b'\x3b', b'\x3c', b'\x3d', b'\xff', b'\xff', b'\xff', b'\xff', b'\xff', 283 b'\xff', b'\xff', b'\x00', b'\x01', b'\x02', b'\x03', b'\x04', b'\x05', b'\x06', 284 b'\x07', b'\x08', b'\x09', b'\x0a', b'\x0b', b'\x0c', b'\x0d', b'\x0e', b'\x0f', 285 b'\x10', b'\x11', b'\x12', b'\x13', b'\x14', b'\x15', b'\x16', b'\x17', b'\x18', 286 b'\x19', b'\xff', b'\xff', b'\xff', b'\xff', b'\xff', b'\xff', b'\x1a', b'\x1b', 287 b'\x1c', b'\x1d', b'\x1e', b'\x1f', b'\x20', b'\x21', b'\x22', b'\x23', b'\x24', 288 b'\x25', b'\x26', b'\x27', b'\x28', b'\x29', b'\x2a', b'\x2b', b'\x2c', b'\x2d', 289 b'\x2e', b'\x2f', b'\x30', b'\x31', b'\x32', b'\x33', b'\xff', b'\xff', b'\xff', 290 b'\xff', b'\xff', b'\xff', b'\xff', b'\xff', b'\xff', b'\xff', b'\xff', b'\xff', 291 b'\xff', b'\xff', b'\xff', b'\xff', b'\xff', b'\xff', b'\xff', b'\xff', b'\xff', 292 b'\xff', b'\xff', b'\xff', b'\xff', b'\xff', b'\xff', b'\xff', b'\xff', b'\xff', 293 b'\xff', b'\xff', b'\xff', b'\xff', b'\xff', b'\xff', b'\xff', b'\xff', b'\xff', 294 b'\xff', b'\xff', b'\xff', b'\xff', b'\xff', b'\xff', b'\xff', b'\xff', b'\xff', 295 b'\xff', b'\xff', b'\xff', b'\xff', b'\xff', b'\xff', b'\xff', b'\xff', b'\xff', 296 b'\xff', b'\xff', b'\xff', b'\xff', b'\xff', b'\xff', b'\xff', b'\xff', b'\xff', 297 b'\xff', b'\xff', b'\xff', b'\xff', b'\xff', b'\xff', b'\xff', b'\xff', b'\xff', 298 b'\xff', b'\xff', b'\xff', b'\xff', b'\xff', b'\xff', b'\xff', b'\xff', b'\xff', 299 b'\xff', b'\xff', b'\xff', b'\xff', b'\xff', b'\xff', b'\xff', b'\xff', b'\xff', 300 b'\xff', b'\xff', b'\xff', b'\xff', b'\xff', b'\xff', b'\xff', b'\xff', b'\xff', 301 b'\xff', b'\xff', b'\xff', b'\xff', b'\xff', b'\xff', b'\xff', b'\xff', b'\xff', 302 b'\xff', b'\xff', b'\xff', b'\xff', b'\xff', b'\xff', b'\xff', b'\xff', b'\xff', 303 b'\xff', b'\xff', b'\xff', b'\xff', b'\xff', b'\xff', b'\xff', b'\xff', b'\xff', 304 b'\xff', b'\xff', b'\xff', b'\xff', 305] 306 307///| 308let
FixedArray[Byte]
url_decode_map
:
type FixedArray[A]
FixedArray
[
Byte
Byte
] = [
309 b'\xff', b'\xff', b'\xff', b'\xff', b'\xff', b'\xff', b'\xff', b'\xff', b'\xff', 310 b'\xff', b'\xff', b'\xff', b'\xff', b'\xff', b'\xff', b'\xff', b'\xff', b'\xff', 311 b'\xff', b'\xff', b'\xff', b'\xff', b'\xff', b'\xff', b'\xff', b'\xff', b'\xff', 312 b'\xff', b'\xff', b'\xff', b'\xff', b'\xff', b'\xff', b'\xff', b'\xff', b'\xff', 313 b'\xff', b'\xff', b'\xff', b'\xff', b'\xff', b'\xff', b'\xff', b'\xff', b'\xff', 314 b'\x3e', b'\xff', b'\xff', b'\x34', b'\x35', b'\x36', b'\x37', b'\x38', b'\x39', 315 b'\x3a', b'\x3b', b'\x3c', b'\x3d', b'\xff', b'\xff', b'\xff', b'\xff', b'\xff', 316 b'\xff', b'\xff', b'\x00', b'\x01', b'\x02', b'\x03', b'\x04', b'\x05', b'\x06', 317 b'\x07', b'\x08', b'\x09', b'\x0a', b'\x0b', b'\x0c', b'\x0d', b'\x0e', b'\x0f', 318 b'\x10', b'\x11', b'\x12', b'\x13', b'\x14', b'\x15', b'\x16', b'\x17', b'\x18', 319 b'\x19', b'\xff', b'\xff', b'\xff', b'\xff', b'\x3f', b'\xff', b'\x1a', b'\x1b', 320 b'\x1c', b'\x1d', b'\x1e', b'\x1f', b'\x20', b'\x21', b'\x22', b'\x23', b'\x24', 321 b'\x25', b'\x26', b'\x27', b'\x28', b'\x29', b'\x2a', b'\x2b', b'\x2c', b'\x2d', 322 b'\x2e', b'\x2f', b'\x30', b'\x31', b'\x32', b'\x33', b'\xff', b'\xff', b'\xff', 323 b'\xff', b'\xff', b'\xff', b'\xff', b'\xff', b'\xff', b'\xff', b'\xff', b'\xff', 324 b'\xff', b'\xff', b'\xff', b'\xff', b'\xff', b'\xff', b'\xff', b'\xff', b'\xff', 325 b'\xff', b'\xff', b'\xff', b'\xff', b'\xff', b'\xff', b'\xff', b'\xff', b'\xff', 326 b'\xff', b'\xff', b'\xff', b'\xff', b'\xff', b'\xff', b'\xff', b'\xff', b'\xff', 327 b'\xff', b'\xff', b'\xff', b'\xff', b'\xff', b'\xff', b'\xff', b'\xff', b'\xff', 328 b'\xff', b'\xff', b'\xff', b'\xff', b'\xff', b'\xff', b'\xff', b'\xff', b'\xff', 329 b'\xff', b'\xff', b'\xff', b'\xff', b'\xff', b'\xff', b'\xff', b'\xff', b'\xff', 330 b'\xff', b'\xff', b'\xff', b'\xff', b'\xff', b'\xff', b'\xff', b'\xff', b'\xff', 331 b'\xff', b'\xff', b'\xff', b'\xff', b'\xff', b'\xff', b'\xff', b'\xff', b'\xff', 332 b'\xff', b'\xff', b'\xff', b'\xff', b'\xff', b'\xff', b'\xff', b'\xff', b'\xff', 333 b'\xff', b'\xff', b'\xff', b'\xff', b'\xff', b'\xff', b'\xff', b'\xff', b'\xff', 334 b'\xff', b'\xff', b'\xff', b'\xff', b'\xff', b'\xff', b'\xff', b'\xff', b'\xff', 335 b'\xff', b'\xff', b'\xff', b'\xff', b'\xff', b'\xff', b'\xff', b'\xff', b'\xff', 336 b'\xff', b'\xff', b'\xff', b'\xff', b'\xff', b'\xff', b'\xff', b'\xff', b'\xff', 337 b'\xff', b'\xff', b'\xff', b'\xff', 338] 339