String
Source: std/string.mw.
C strings are plain *u8 values ending in a zero byte. String is the growable owned variant.
String
Section titled “String”struct String { data: *u8; len: i64; cap: i64;}Functions
Section titled “Functions”str_len
Section titled “str_len”fn str_len(s: *u8) -> i64str_eq
Section titled “str_eq”fn str_eq(s1: *u8, s2: *u8) -> i8is_digit
Section titled “is_digit”fn is_digit(c: u8) -> i8is_alpha
Section titled “is_alpha”fn is_alpha(c: u8) -> i8is_space
Section titled “is_space”fn is_space(c: u8) -> i8string_new
Section titled “string_new”fn string_new(initial_cap: i64) -> ^Stringstring_from
Section titled “string_from”fn string_from(raw_str: *u8) -> *Stringstring_push_char
Section titled “string_push_char”fn string_push_char(s: *String, c: u8)string_push_str
Section titled “string_push_str”fn string_push_str(s: *String, raw_str: *u8)string_free
Section titled “string_free”fn string_free(s: ^String)fn string_destroy(s: *String)fn string_into_data(s: ^String) -> *u8A ^String frees itself at the end of its scope. string_free drops it at once, string_destroy frees one held by a plain pointer. string_into_data gives the buffer to the caller (free it with dealloc) and frees only the String.
string_eq
Section titled “string_eq”fn string_eq(a: *String, b: *String) -> i32string_cmp
Section titled “string_cmp”fn string_cmp(a: *String, b: *String) -> i32