tur/str

stdlib/str.tur
defn

str-from-cstr

(str-from-cstr [cstr])

create a str view from a NUL-terminated C string.

cstrNUL-terminated C string pointer
Pointer to a newly allocated str struct (p + len). Does not copy the
  underlying string data; the caller retains ownership of the original buffer.

  (str-from-cstr "hello")  ; => <str ptr>
defn

str-len

(str-len [s] :int)

return the length of a str in bytes.

sstr pointer returned by str-from-cstr
Length of the string in bytes (not characters).

  (str-len (str-from-cstr "hello"))  ; => 5
defn

str-eq?

(str-eq? [s1 s2] :bool)

check whether two str values have identical byte contents.

s1first str pointer
s2second str pointer

Since: Phase E1

defn

str-free

(str-free [s])

free the str struct (does not free the underlying string data).

sstr pointer to free
(str-free my-str)
definstance

Eq[str]

(definstance Eq [str])

eq? delegates to str-eq? for byte-level string equality.