No matching definitions.

tur/string

stdlib/string.tur

owned, immutable, refcounted String.

Since: v2 (owned-string-type-plan)

defopaque

String

(String)
defopaque

StringBuilder

(StringBuilder)
defn

string/from-cstr

(string/from-cstr [s : cstr] :)

copy a NUL-terminated C string into a fresh owned String.

sthe source cstr (a literal or borrowed buffer); its bytes are copied

A new String (refcount 1) owning a private copy of s's bytes.

(string/from-cstr "hello")  ; => String "hello"

Since: v2

defn

string/to-cstr

(string/to-cstr [s : String] :)

borrow the String's NUL-terminated bytes (O(1), no copy).

sthe String to borrow from

A borrowed cstr view of the same bytes.

(string/to-cstr (string/from-cstr "hi"))  ; => "hi"

Since: v2

defn

string/adopt-cstr

(string/adopt-cstr [s : cstr] :)

take ownership of a freshly-allocated cstr as a String.

sa freshly heap-allocated NUL-terminated cstr; consumed (freed)

A new owned String holding a copy of s's bytes.

Since: v2 (string-adoption-stdlib-plan, batch 1)

defn

int->string

(int->string [v : int] :)

format a signed integer as a fresh owned decimal String.

vthe integer to render

A new owned String, e.g. (int->string -7) => String "-7".

(string/to-cstr (int->string 42))  ; => "42"

Since: v2 (string-adoption-stdlib-plan, batch 1)

defn

string/retain

(string/retain [s : String] :)

increment the refcount, returning a second owning handle.

Since: v2

defn

string/release

(string/release [s : String] :)

decrement the refcount; free the payload at zero.

Since: v2

defn

string/len

(string/len [s : String] :)

byte length of the String (not counting the NUL).

Since: v2

defn

string/empty?

(string/empty? [s : String] :)

true iff the String has length zero.

Since: v2

defn

string/byte-at

(string/byte-at [s : String i : int] :)

the byte (0..255) at index i, or -1 if out of range.

Since: v2

defn

string/eq?

(string/eq? [a : String b : String] :)

content equality (length then byte compare).

Since: v2

defn

string/compare

(string/compare [a : String b : String] :)

lexicographic byte compare: -1, 0, or 1.

Since: v2

defn

string/hash

(string/hash [s : String] :)

content hash over the exact byte range (length-aware).

Since: v2

defn

string/starts-with?

(string/starts-with? [s : String prefix : String] :)

true iff s begins with prefix.

Since: v2

defn

string/ends-with?

(string/ends-with? [s : String suffix : String] :)

true iff s ends with suffix.

Since: v2

defn

string/contains?

(string/contains? [s : String needle : String] :)

true iff needle occurs as a substring of s.

Since: v2

defn

string/concat

(string/concat [a : String b : String] :)

concatenate two Strings into a fresh String.

Since: v2

defn

string/substring

(string/substring [s : String start : int len : int] :)

fresh String of len bytes starting at start (clamped).

Since: v2

defn

string/to-upper

(string/to-upper [s : String] :)

ASCII-uppercased copy.

Since: v2

defn

string/to-lower

(string/to-lower [s : String] :)

ASCII-lowercased copy.

Since: v2

defn

string/trim

(string/trim [s : String] :)

copy with ASCII leading/trailing whitespace removed.

Since: v2

defn

builder/new

(builder/new :)

a fresh empty StringBuilder (mutable, growable byte buffer).

Since: v2

defn

builder/push-cstr!

(builder/push-cstr! [b : StringBuilder s : cstr] :)

append a cstr's bytes to the builder.

Since: v2

defn

builder/push-string!

(builder/push-string! [b : StringBuilder s : String] :)

append a String's bytes to the builder.

Since: v2

defn

builder/push-byte!

(builder/push-byte! [b : StringBuilder c : int] :)

append a single byte (0..255) to the builder.

Since: v2

defn

builder/len

(builder/len [b : StringBuilder] :)

number of bytes accumulated so far.

Since: v2

defn

builder/finish

(builder/finish [b : StringBuilder] :)

freeze the accumulated bytes into an immutable String.

(let [b (builder/new)]
    (do (builder/push-cstr! b "a")
        (builder/push-cstr! b "b")
        (builder/finish b)))  ; => String "ab"

Since: v2

definstance

Eq[String]

(definstance Eq [String])

content equality.

definstance

Ord[String]

(definstance Ord [String])

lexicographic byte ordering.

definstance

Hash[String]

(definstance Hash [String])

content hash over the byte range.

definstance

Clone[String]

(definstance Clone [String])

O(1) retain (refcount++), returning a second owning handle.

definstance

Drop[String]

(definstance Drop [String])

release one owning handle (refcount--), freeing at zero.

Since: v2 (Model R)

definstance

MapKey[String]

(definstance MapKey [String])

owned key: the map copies the bytes into a boxed key it

Internal definitions