Reference
std/ptr
std/ptr
Ptr<T>, a raw pointer for unsafe code and C.
narra
import * as Ptr from "std/ptr"
The guide teaches it in chapter 16, Unsafe code and C.
This page is generated by scripts/std/generate.nra from narrac query --json interface std/ptr. Do not edit it.
Types
Ptr
narra
export opaque struct Ptr<T>
Functions: alloc, cast, element, free, isNull, null, offset, read, write.
Functions
alloc
narra
export function alloc<T>(count: int): Ptr<T> uses alloc, unsafe
Effects: alloc, unsafe.
cast
narra
export function cast<T, U>(pointer: Ptr<T>): Ptr<U> uses unsafe
Effects: unsafe.
element
narra
export function element<T, const N: int>(pointer: Ptr<FixedArray<T, N>>, index: int): Ptr<T> uses unsafe
Effects: unsafe.
Details: index: a constant or a name proven to be 0 to N - 1.
free
narra
export function free<T>(pointer: Ptr<T>) uses unsafe
Effects: unsafe.
isNull
narra
export function isNull<T>(pointer: Ptr<T>): bool
Effects: none.
null
narra
export function null<T>(): Ptr<T>
Effects: none.
offset
narra
export function offset<T>(pointer: Ptr<T>, count: int): Ptr<T> uses unsafe
Effects: unsafe.
read
narra
export function read<T>(pointer: Ptr<T>): T uses unsafe
Effects: unsafe.
write
narra
export function write<T>(pointer: Ptr<T>, value: T) uses unsafe
Effects: unsafe.