Zig 0.17.0-dev (Split by item)

This is an example of documentation generated by ZigDoc, an alternative to Zig's built-in Auto Doc feature. See also examples in other modes/formats. The project being documented here (as the example) is the Zig library itself.

splitSequence

Returns an iterator that iterates over the slices of buffer that are separated by the byte sequence in delimiter.

splitSequence(u8, "abc||def||||ghi", "||") will return slices for "abc", "def", "", "ghi", null, in that order.

If delimiter does not exist in buffer, the iterator will return buffer, null, in that order. The delimiter length must not be zero.

See also: splitAny, splitScalar, splitBackwardsSequence, splitBackwardsAny,splitBackwardsScalar, tokenizeAny, tokenizeSequence, and tokenizeScalar.

mem.splitSequence
pub fn splitSequence(comptime T: type, buffer: []const T, delimiter: []const T) SplitIterator(T, .sequence)

File

lib/std/mem.zig:2592

Code

pub fn splitSequence(comptime T: type, buffer: []const T, delimiter: []const T) SplitIterator(T, .sequence) {
    assert(delimiter.len != 0);
    return .{
        .index = 0,
        .buffer = buffer,
        .delimiter = delimiter,
    };
}