nupp.mem.array

Owned contiguous arrays. Views use the ordinary nupp.mem.span contracts.

Module contents

Constructors

ConstructorDescription
newAllocates zeroed storage with the struct witness's physical layout.

Types

TypeKindDescription
Arrayrecord
BytesrecordOwned bytes, with the same checked view vocabulary as scalar arrays.
Scalarrecord

Functions

FunctionKindDescription
bytesfunctionAllocates zeroed bytes without treating the storage-only uint8 as a value type.
scalarfunctionAllocates zeroed storage for the selected scalar element type.

Constructors#

array.newconstructor#

function array.new<T>(takes witness: T, count: integer): array.Array<T>

Allocates zeroed storage with the struct witness's physical layout.

Type parameters

NameDescription
T

Arguments

NameTypeDescription
takes witnessT
countinteger

Returns

TypeDescription
array.Array<T>

Types#

Arrayrecord#

record array.Array<T>
    readonly count: integer
    read: function(borrows self: Array<T>): span.Span<T> borrows (self)
    write: function(exclusive self: Array<T>): span.Writable<T> borrows (self)
end

Type parameters

NameDescription
T

Methods

read#
read: function(borrows self: Array<T>): span.Span<T> borrows (self)
Arguments
NameTypeDescription
borrows selfArray<T>
Returns
TypeDescription
span.Span<T> borrows (self)
write#
write: function(exclusive self: Array<T>): span.Writable<T> borrows (self)
Arguments
NameTypeDescription
exclusive selfArray<T>
Returns
TypeDescription
span.Writable<T> borrows (self)

Fields

count#
count: integer

Bytesrecord#

record array.Bytes
    readonly count: integer

    function read(borrows self): span.ByteSpan borrows (self) end

    function write(exclusive self): span.Writable<uint8> borrows (self) end
end

Owned bytes, with the same checked view vocabulary as scalar arrays.

Methods

read#
read: function read(borrows self): span.ByteSpan
Arguments
NameTypeDescription
borrows selfany
Returns
TypeDescription
span.ByteSpan
write#
write: function write(exclusive self): span.Writable<uint8>
Arguments
NameTypeDescription
exclusive selfany
Returns
TypeDescription
span.Writable<uint8>

Fields

count#
count: integer

Scalarrecord#

record array.Scalar<T>
end

Type parameters

NameDescription
T

Functions#

array.bytesfunction#

function array.bytes(count: integer): array.Bytes

Allocates zeroed bytes without treating the storage-only uint8 as a value type.

Arguments

NameTypeDescription
countinteger

Returns

TypeDescription
array.Bytes

Raises

  • when count is not a non-negative integer

array.scalarfunction#

function array.scalar<T>(borrows witness: array.Scalar<T>, count: integer): array.Array<T>

Allocates zeroed storage for the selected scalar element type.

Type parameters

NameDescription
T

Arguments

NameTypeDescription
borrows witnessarray.Scalar<T>
countinteger

Returns

TypeDescription
array.Array<T>