mirror of
https://codeberg.org/ziglang/zig.git
synced 2025-12-06 13:54:21 +00:00
document bufPrint, and format now uses writer not output
This commit is contained in:
parent
64de32b341
commit
8171972cbb
1 changed files with 6 additions and 3 deletions
|
|
@ -24,9 +24,9 @@ pub const FormatOptions = struct {
|
||||||
fill: u8 = ' ',
|
fill: u8 = ' ',
|
||||||
};
|
};
|
||||||
|
|
||||||
/// Renders fmt string with args, calling output with slices of bytes.
|
/// Renders fmt string with args, calling `writer` with slices of bytes.
|
||||||
/// If `output` returns an error, the error is returned from `format` and
|
/// If `writer` returns an error, the error is returned from `format` and
|
||||||
/// `output` is not called again.
|
/// `writer` is not called again.
|
||||||
///
|
///
|
||||||
/// The format string must be comptime known and may contain placeholders following
|
/// The format string must be comptime known and may contain placeholders following
|
||||||
/// this format:
|
/// this format:
|
||||||
|
|
@ -1869,6 +1869,9 @@ pub const BufPrintError = error{
|
||||||
/// As much as possible was written to the buffer, but it was too small to fit all the printed bytes.
|
/// As much as possible was written to the buffer, but it was too small to fit all the printed bytes.
|
||||||
NoSpaceLeft,
|
NoSpaceLeft,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/// print a Formatter string into `buf`. Actually just a thin wrapper around `format` and `fixedBufferStream`.
|
||||||
|
/// returns a slice of the bytes printed to.
|
||||||
pub fn bufPrint(buf: []u8, comptime fmt: []const u8, args: anytype) BufPrintError![]u8 {
|
pub fn bufPrint(buf: []u8, comptime fmt: []const u8, args: anytype) BufPrintError![]u8 {
|
||||||
var fbs = std.io.fixedBufferStream(buf);
|
var fbs = std.io.fixedBufferStream(buf);
|
||||||
try format(fbs.writer(), fmt, args);
|
try format(fbs.writer(), fmt, args);
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue