Commit e255415498
Changed files (2)
lib
std
lib/std/Io/Reader.zig
@@ -840,6 +840,9 @@ pub fn peekDelimiterExclusive(r: *Reader, delimiter: u8) DelimiterError![]u8 {
/// Returns number of bytes streamed, which may be zero, or error.EndOfStream
/// if the delimiter was not found.
///
+/// Asserts buffer capacity of at least one. This function performs better with
+/// larger buffers.
+///
/// See also:
/// * `streamDelimiterEnding`
/// * `streamDelimiterLimit`
@@ -858,6 +861,9 @@ pub fn streamDelimiter(r: *Reader, w: *Writer, delimiter: u8) StreamError!usize
/// Returns number of bytes streamed, which may be zero. End of stream can be
/// detected by checking if the next byte in the stream is the delimiter.
///
+/// Asserts buffer capacity of at least one. This function performs better with
+/// larger buffers.
+///
/// See also:
/// * `streamDelimiter`
/// * `streamDelimiterLimit`
@@ -884,6 +890,9 @@ pub const StreamDelimiterLimitError = error{
///
/// Returns number of bytes streamed, which may be zero. End of stream can be
/// detected by checking if the next byte in the stream is the delimiter.
+///
+/// Asserts buffer capacity of at least one. This function performs better with
+/// larger buffers.
pub fn streamDelimiterLimit(
r: *Reader,
w: *Writer,
lib/std/Io/Writer.zig
@@ -560,6 +560,10 @@ pub fn writeAllPreserve(w: *Writer, preserve_length: usize, bytes: []const u8) E
/// A user type may be a `struct`, `vector`, `union` or `enum` type.
///
/// To print literal curly braces, escape them by writing them twice, e.g. `{{` or `}}`.
+///
+/// Asserts `buffer` capacity of at least 2 if a union is printed. This
+/// requirement could be lifted by adjusting the code, but if you trigger that
+/// assertion it is a clue that you should probably be using a buffer.
pub fn print(w: *Writer, comptime fmt: []const u8, args: anytype) Error!void {
const ArgsType = @TypeOf(args);
const args_type_info = @typeInfo(ArgsType);
@@ -930,6 +934,7 @@ pub fn printAddress(w: *Writer, value: anytype) Error!void {
@compileError("cannot format non-pointer type " ++ @typeName(T) ++ " with * specifier");
}
+/// Asserts `buffer` capacity of at least 2 if `value` is a union.
pub fn printValue(
w: *Writer,
comptime fmt: []const u8,