tur/str-build-string
stdlib/str-build-string.tur
owned String siblings for the cstr builders.
Since: v2 (string-owned-builders-and-optional-accessors-plan, Part 1)
defn
str-concat-string
(str-concat-string [a : cstr b : cstr] :)
concatenate two cstrs into a fresh owned String.
Parameters
| a | first cstr (NUL-terminated) | |
| b | second cstr (NUL-terminated) |
Returns
A fresh owned String holding a followed by b.
Example
(string/to-cstr (str-concat-string "Hello, " "world")) ; => "Hello, world"
Since: v2
defn
cstr-sub-string
(cstr-sub-string [s : cstr start : int end : int] :)
substring [start, end) of a cstr, as a fresh owned String.
Parameters
| s | NUL-terminated cstr | |
| start | zero-based start byte index (clamped into [0, len]) | |
| end | exclusive end byte index (clamped into [start, len]) |
Returns
A fresh owned String holding the bytes of s in [start, end).
Example
(string/to-cstr (cstr-sub-string "hello" 1 4)) ; => "ell"
Since: v2