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.

takeValueSliceMinusTrailingOffset

Scanner.takeValueSliceMinusTrailingOffset
fn takeValueSliceMinusTrailingOffset(self: *@This(), trailing_negative_offset: usize) []const u8

File

lib/std/json/Scanner.zig:1326

Code

fn takeValueSliceMinusTrailingOffset(self: *@This(), trailing_negative_offset: usize) []const u8 {
    // Check if the escape sequence started before the current input buffer.
    // (The algebra here is awkward to avoid unsigned underflow,
    //  but it's just making sure the slice on the next line isn't UB.)
    if (self.cursor <= self.value_start + trailing_negative_offset) return "";
    const slice = self.input[self.value_start .. self.cursor - trailing_negative_offset];
    // When trailing_negative_offset is non-zero, setting self.value_start doesn't matter,
    // because we always set it again while emitting the .partial_string_escaped_*.
    self.value_start = self.cursor;
    return slice;
}