Zig 0.17.0-dev (Split by item)

Shortcut keys
?
Show these tips
S
Focus search field
Esc
Clear focus & close tips
U
Jump to source code
↑
Move up in search results
↓
Move down in search results
↵
Go to active search result
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 Function

drain

Private Function
std.zig.StringEscapeWriter.drain
fn drain(w: *Writer, data: []const []const u8, splat: usize) Io.Writer.Error!usize

Params

  • w: *Writer
  • data: []const []const u8
  • splat: usize

File

zig.zig:601
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
    fn drain(w: *Writer, data: []const []const u8, splat: usize) Io.Writer.Error!usize {
        const sew: *StringEscapeWriter = @alignCast(@fieldParentPtr("writer", w));
        const out = sew.out;
        try stringEscape(w.buffered(), out);
        w.end = 0;
        var n: usize = 0;
        for (data[0 .. data.len - 1]) |bytes| {
            try stringEscape(bytes, out);
            n += bytes.len;
        }
        const pattern = data[data.len - 1];
        for (0..splat) |_| {
            try stringEscape(pattern, out);
            n += pattern.len;
        }
        return n;
    }