std.mem
slice helpers; generics take the element type first: copy(u8, dst, src)
pub eql :: fn($T: type, self: []const T, b: []const T) -> boolstarts_with
Section titled “starts_with”pub starts_with :: fn($T: type, self: []const T, prefix: []const T) -> boolends_with
Section titled “ends_with”pub ends_with :: fn($T: type, self: []const T, suffix: []const T) -> boolpub copy :: fn($T: type, self: []T, source: []const T) -> usizecopies min(len) elements, returns the count; must not overlap
pub fill :: fn($T: type, self: []T, value: T)pub swap :: fn($T: type, self: []T, i: usize, j: usize)reverse
Section titled “reverse”pub reverse :: fn($T: type, self: []T)index_of
Section titled “index_of”pub index_of :: fn($T: type, self: []const T, needle: T) -> ?usizecontains
Section titled “contains”pub contains :: fn($T: type, self: []const T, needle: T) -> booleql_bytes
Section titled “eql_bytes”pub eql_bytes :: fn(self: []const u8, b: []const u8) -> boolcompare_bytes
Section titled “compare_bytes”pub compare_bytes :: fn(self: []const u8, b: []const u8) -> i32byte order: -1, 0 or 1; a prefix sorts first
less_bytes
Section titled “less_bytes”pub less_bytes :: fn(self: []const u8, b: []const u8) -> boolbyte-order less-than; for sort::by
copy_bytes
Section titled “copy_bytes”pub copy_bytes :: fn(self: []u8, source: []const u8) -> usizepub zero :: fn(self: []u8)index_of_slice
Section titled “index_of_slice”pub index_of_slice :: fn($T: type, self: []const T, needle: []const T) -> ?usizefirst start of needle in self, or null; empty needle -> 0
last_index_of
Section titled “last_index_of”pub last_index_of :: fn($T: type, self: []const T, needle: T) -> ?usizelast_index_of_slice
Section titled “last_index_of_slice”pub last_index_of_slice :: fn($T: type, self: []const T, needle: []const T) -> ?usizepub count :: fn($T: type, self: []const T, needle: []const T) -> usizenon-overlapping occurrences; empty needle -> 0
trim_left
Section titled “trim_left”pub trim_left :: fn($T: type, self: []const T, set: []const T) -> []const Tdrops leading elements in set
trim_right
Section titled “trim_right”pub trim_right :: fn($T: type, self: []const T, set: []const T) -> []const Tdrops trailing elements in set
pub trim :: fn($T: type, self: []const T, set: []const T) -> []const Tboth ends
pub Split :: struct($T: type) { rest: []const T, sep: []const T, done: bool,}parts between separators, empty ones kept: “a,,b” -> “a”, “”, “b”
Split.next
Section titled “Split.next”pub next :: fn(self: *Self) -> ?[]const TSplit.remaining
Section titled “Split.remaining”pub remaining :: fn(self: *Self) -> []const Tthe unsplit rest
pub split :: fn($T: type, self: []const T, sep: []const T) -> Split(T)empty sep gives self as one part
Tokens
Section titled “Tokens”pub Tokens :: struct($T: type) { rest: []const T, delims: []const T,}parts between runs of delimiters, empty ones skipped
Tokens.next
Section titled “Tokens.next”pub next :: fn(self: *Self) -> ?[]const Ttokenize
Section titled “tokenize”pub tokenize :: fn($T: type, self: []const T, delims: []const T) -> Tokens(T)any element of delims splits
Halves
Section titled “Halves”pub Halves :: struct($T: type) { before: []const T, after: []const T,}result of split_once
split_once
Section titled “split_once”pub split_once :: fn($T: type, self: []const T, sep: []const T) -> ?Halves(T)before and after the first sep, or null if absent