session/ownstr
src/session/ownstr.tur
owned String surface for the session spice.
Since: v0.3.0
defopaque
String
(String)
an owned, refcounted, immutable string (ABI: ptr<void>).
defn
ownstr-autolink
(ownstr-autolink :)
internal: pull src/runtime/tur_string.c into the link.
defn
adopt-cstr
(adopt-cstr [s : cstr] :)
defn
to-cstr
(to-cstr [s : String] :)
borrow the String's NUL-terminated bytes (O(1), no copy).
Parameters
| s | the String to borrow from |
Returns
cstr -- a borrowed view of the same bytes.
Since: v0.3.0
defn
release
(release [s : String] :)
decrement the refcount; free the payload at zero.
Parameters
| s | the String whose owning handle is being dropped |
Since: v0.3.0
defn
str-len
(str-len [s : String] :)
byte length of the String (not counting the NUL).
Parameters
| s | the String to measure |
Returns
int -- the byte length.
Since: v0.3.0
Internal definitions
__adopt-cstr-raw-- take ownership of a freshly heap-allocated cstr as a String.