Skip to content

std/unsafe

Index

fn Str(b: *byte, n: int): str
fn Slice[Elem](e: *Elem, len: int, cap: int): []Elem
fn Bytes(b: *byte, n: int): []byte
fn StrBytes(s: str): []byte
fn BytesStr(b: []byte): str
fn StrFromBytes(b: []byte): str
fn BytesFromStr(s: str): []byte

Str

jule
fn Str(b: *byte, n: int): str

Returns string based on b, the parameter b means first byte of string. The returned string uses n as length. Will not perform garbage collection.

Slice

jule
fn Slice[Elem](e: *Elem, len: int, cap: int): []Elem

Returns slice based on e, the parameter e means first element of slice. Will not perform garbage collection.

Bytes

jule
fn Bytes(b: *byte, n: int): []byte

Alias for Slice(b, n, n).

StrBytes

jule
fn StrBytes(s: str): []byte

Alias for Slice(&s[0], len(s), len(s)). Returns nil if len(s) == 0.

BytesStr

jule
fn BytesStr(b: []byte): str

Alias for Str(&b[0], len(b), len(b)). Returns empty string if len(b) == 0.

StrFromBytes

jule
fn StrFromBytes(b: []byte): str

Same as [BytesStr] but keeps garbage collection.

BytesFromStr

jule
fn BytesFromStr(s: str): []byte

Same as [StrBytes] but keeps garbage collection.