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 standard library. Private Type Function
Self
Private Type Function
std.mem.SplitBackwardsIterator.Self
pubfnSplitBackwardsIterator(comptimeT: type, comptimedelimiter_type: DelimiterType) type
Iterator type for splitting operations from the end backwards, including empty sequences.
pubfnSplitBackwardsIterator(comptimeT: type, comptimedelimiter_type: DelimiterType) type {
returnstruct {
buffer: []constT,
index: ?usize,
delimiter: switch (delimiter_type) {
.sequence, .any => []constT,
.scalar => T,
},
constSelf = @This();
/// Returns a slice of the first field./// Call this only to get the first field and then use `next` to get all subsequent fields./// Asserts that iteration has not begun.pubfnfirst(self: *Self) []constT {
assert(self.index.? == self.buffer.len);
returnself.next().?;
}
/// Returns a slice of the next field, or null if splitting is complete.pubfnnext(self: *Self) ?[]constT {
constend = self.indexorelsereturnnull;
conststart = if (switch (delimiter_type) {
.sequence => findLast(T, self.buffer[0..end], self.delimiter),
.any => findLastAny(T, self.buffer[0..end], self.delimiter),
.scalar => findScalarLast(T, self.buffer[0..end], self.delimiter),
}) |delim_start| blk: {
self.index = delim_start;
break :blkdelim_start + switch (delimiter_type) {
.sequence => self.delimiter.len,
.any, .scalar => 1,
};
} elseblk: {
self.index = null;
break :blk0;
};
returnself.buffer[start..end];
}
/// Returns a slice of the remaining bytes. Does not affect iterator state.pubfnrest(self: Self) []constT {
constend = self.indexorelse0;
returnself.buffer[0..end];
}
/// Resets the iterator to the initial slice.pubfnreset(self: *Self) void {
self.index = self.buffer.len;
}
};
}
Iterator type for splitting operations from the end backwards, including empty sequences.