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] :String)

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] :cstr)

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] :String)

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] :String)

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] :String)

increment the refcount, returning a second owning handle.

Since: v2

defn

string/release

(string/release [s :String] :void)

decrement the refcount; free the payload at zero.

Since: v2

defn

string/len

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

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

Since: v2

defn

string/empty?

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

true iff the String has length zero.

Since: v2

defn

string/byte-at

(string/byte-at [s :String i :int] :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] :bool)

content equality (length then byte compare).

Since: v2

defn

string/compare

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

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

Since: v2

defn

string/hash

(string/hash [s :String] :int)

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

Since: v2

defn

string/starts-with?

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

true iff s begins with prefix.

Since: v2

defn

string/ends-with?

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

true iff s ends with suffix.

Since: v2

defn

string/contains?

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

true iff needle occurs as a substring of s.

Since: v2

defn

string/concat

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

concatenate two Strings into a fresh String.

Since: v2

defn

string/substring

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

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

Since: v2

defn

string/to-upper

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

ASCII-uppercased copy.

Since: v2

defn

string/to-lower

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

ASCII-lowercased copy.

Since: v2

defn

string/trim

(string/trim [s :String] :String)

copy with ASCII leading/trailing whitespace removed.

Since: v2

defn

builder/new

(builder/new :StringBuilder)

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

Since: v2

defn

builder/push-cstr!

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

append a cstr's bytes to the builder.

Since: v2

defn

builder/push-string!

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

append a String's bytes to the builder.

Since: v2

defn

builder/push-byte!

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

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

Since: v2

defn

builder/len

(builder/len [b :StringBuilder] :int)

number of bytes accumulated so far.

Since: v2

defn

builder/finish

(builder/finish [b :StringBuilder] :String)

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