1///|
2pub fn[T : 
trait Setter {
  set(Ptr[Self], Self) -> Unit
}
Setter
]
type Ptr[T]
Ptr
::
(self : Ptr[T], x : T) -> Unit
set
(
Ptr[T]
self
:
type Ptr[T]
Ptr
[

type parameter T

T
],
T
x
:

type parameter T

T
) ->
Unit
Unit
{
3

type parameter

T
::
(Ptr[T], T) -> Unit
set
(
Ptr[T]
self
,
T
x
)
4} 5 6///| 7pub fn[T :
trait Getter {
  get(ConstPtr[Self]) -> Self
}
Getter
]
type Ptr[T]
Ptr
::
(self : Ptr[T]) -> T
get
(
Ptr[T]
self
:
type Ptr[T]
Ptr
[

type parameter T

T
]) ->

type parameter T

T
{
8

type parameter

T
::
(ConstPtr[T]) -> T
get
(
(x : Ptr[T]) -> ConstPtr[T]
unsafe_coerce
(
Ptr[T]
self
))
9} 10 11///| 12pub fn[T]
type Ptr[T]
Ptr
::
(self : Ptr[T]) -> ConstPtr[T]
to_const_ptr
(
Ptr[T]
self
:
type Ptr[T]
Ptr
[

type parameter T

T
]) ->
type ConstPtr[T]
ConstPtr
[

type parameter T

T
] {
13
(x : Ptr[T]) -> ConstPtr[T]
unsafe_coerce
(
Ptr[T]
self
)
14} 15 16///| 17pub fn[T]
type Ptr[T]
Ptr
::
(self : Ptr[T], other : Ptr[T]) -> Int
compare
(
Ptr[T]
self
:
type Ptr[T]
Ptr
[

type parameter T

T
],
Ptr[T]
other
:
type Ptr[T]
Ptr
[

type parameter T

T
]) ->
Int
Int
{
18
(ptr : ConstPtr[Byte], other : ConstPtr[Byte]) -> Int64
pointer_sub
(
(x : Ptr[T]) -> ConstPtr[Byte]
unsafe_coerce
(
Ptr[T]
self
),
(x : Ptr[T]) -> ConstPtr[Byte]
unsafe_coerce
(
Ptr[T]
other
)).
(self : Int64) -> Int

Converts a 64-bit signed integer to a 32-bit signed integer by truncating higher bits.

Parameters:

  • value : The 64-bit signed integer (Int64) to be converted.

Returns a 32-bit signed integer (Int). Note that values outside the range of 32-bit integers will be truncated, potentially leading to loss of information.

Example:

  let small = 42L
  let big = 2147483648L // 2^31
  inspect(small.to_int(), content="42")
  inspect(big.to_int(), content="-2147483648") // Truncated to Int.min_value
to_int
()
19} 20 21///| 22pub fn[T :
trait Sized {
  size() -> Int64
}
Sized
]
type Ptr[T]
Ptr
::
(self : Ptr[T], offset : Int64) -> Ptr[T]
add
(
Ptr[T]
self
:
type Ptr[T]
Ptr
[

type parameter T

T
],
Int64
offset
:
Int64
Int64
) ->
type Ptr[T]
Ptr
[

type parameter T

T
] {
23
Ptr[T]
self
|>
(x : Ptr[T]) -> ConstPtr[Byte]
unsafe_coerce
|>
(ptr : ConstPtr[Byte], offset : Int64) -> ConstPtr[Byte]
pointer_add
(
Int64
offset
(self : Int64, other : Int64) -> Int64

Multiplies two 64-bit integers.

Parameters:

  • self : The first 64-bit integer operand.
  • other : The second 64-bit integer operand.

Returns the product of the two 64-bit integers. If the result overflows the range of Int64, it will be truncated according to two's complement arithmetic.

Example:

  let a = 42L
  let b = 100L
  inspect(a * b, content="4200")
  let c = -42L
  inspect(c * b, content="-4200")
*

type parameter

T
::
() -> Int64
size
()) |>
(x : ConstPtr[Byte]) -> Ptr[T]
unsafe_coerce
24} 25 26///| 27pub fn[T :
trait Sized {
  size() -> Int64
}
Sized
]
type Ptr[T]
Ptr
::
(self : Ptr[T], other : Ptr[T]) -> Int64
sub
(
Ptr[T]
self
:
type Ptr[T]
Ptr
[

type parameter T

T
],
Ptr[T]
other
:
type Ptr[T]
Ptr
[

type parameter T

T
]) ->
Int64
Int64
{
28 let
ConstPtr[Byte]
lhs
=
(x : Ptr[T]) -> ConstPtr[Byte]
unsafe_coerce
(
Ptr[T]
self
)
29 let
ConstPtr[Byte]
rhs
=
(x : Ptr[T]) -> ConstPtr[Byte]
unsafe_coerce
(
Ptr[T]
other
)
30
(ptr : ConstPtr[Byte], other : ConstPtr[Byte]) -> Int64
pointer_sub
(
ConstPtr[Byte]
lhs
,
ConstPtr[Byte]
rhs
)
(self : Int64, other : Int64) -> Int64

Performs integer division between two 64-bit integers. Truncates the result towards zero.

Parameters:

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

Returns the quotient of the division.

Throws a panic if other is zero.

Example:

  let a = 42L
  let b = 5L
  inspect(a / b, content="8")
  let c = -42L
  let d = 5L
  inspect(c / d, content="-8")
/

type parameter

T
::
() -> Int64
size
()
31} 32 33///| 34pub fn[T]
type Ptr[T]
Ptr
::
(rc : Rc[FixedArray[T]]) -> Ptr[T]
from_rc_fixedarray
(
Rc[FixedArray[T]]
rc
:
type Rc[T]
Rc
[
type FixedArray[A]
FixedArray
[

type parameter T

T
]]) ->
type Ptr[T]
Ptr
[

type parameter T

T
] {
35
(x : Rc[FixedArray[T]]) -> Ptr[T]
unsafe_coerce
(
Rc[FixedArray[T]]
rc
)
36} 37