A string that views length bytes at s, without copying them. Nothing is allocated, so the string
is valid as long as the bytes are.
to_string :: (s: *u8, length: s64) -> string
Parameters
- s: *u8
- length: s64
Returns
- string
bytes := "hello".data;
view := to_string(bytes, 4);
assert(view == "hell");to_string :: (c_string: [] u8) -> string
A string that views the bytes of c_string up to the first zero byte, or all of them when there is none.
The bytes are not copied.
Parameters
- c_string: [] u8
Returns
- string
buffer: [8] u8;
buffer[0] = #char "h";
buffer[1] = #char "i";
assert(to_string(buffer) == "hi");