@@ -152,7 +152,7 @@ pub fn writeStreamArbitraryDepth(
152
152
/// | <object>
153
153
/// | <array>
154
154
/// | write
155
- /// | writePreformatted
155
+ /// | print
156
156
/// <object> = beginObject ( objectField <value> )* endObject
157
157
/// <array> = beginArray ( <value> )* endArray
158
158
/// ```
@@ -378,13 +378,14 @@ pub fn WriteStream(
378
378
return self .indent_level == 0 and self .next_punctuation == .comma ;
379
379
}
380
380
381
- /// An alternative to calling `write` that outputs the given bytes verbatim .
381
+ /// An alternative to calling `write` that formats a value with `std.fmt` .
382
382
/// This function does the usual punctuation and indentation formatting
383
- /// assuming the given slice represents a single complete value;
383
+ /// assuming the resulting formatted string represents a single complete value;
384
384
/// e.g. `"1"`, `"[]"`, `"[1,2]"`, not `"1,2"`.
385
- pub fn writePreformatted (self : * Self , value_slice : []const u8 ) Error ! void {
385
+ /// This function may be useful for doing your own number formatting.
386
+ pub fn print (self : * Self , comptime fmt : []const u8 , args : anytype ) Error ! void {
386
387
try self .valueStart ();
387
- try self .stream .writeAll ( value_slice );
388
+ try self .stream .print ( fmt , args );
388
389
self .valueDone ();
389
390
}
390
391
@@ -584,6 +585,7 @@ pub fn WriteStream(
584
585
pub const emitNumber = @compileError ("Deprecated; Use .write() instead." );
585
586
pub const emitString = @compileError ("Deprecated; Use .write() instead." );
586
587
pub const emitJson = @compileError ("Deprecated; Use .write() instead." );
588
+ pub const writePreformatted = @compileError ("Deprecated; Use .print(\" {s}\" , .{s}) instead." );
587
589
};
588
590
}
589
591
0 commit comments