doc: remove unnecessary anyerror keyword
All checks were successful
Zig Project Action / Lint, Spell-check and test zig project (push) Successful in 2m28s

Error union return type for format function documentation (and sample
implementation) has been adjusted. This results in the exact same code,
but without unnecessary error type definition, which is derived from the
compiler anyway.
This commit is contained in:
2025-01-15 10:41:03 +01:00
parent 2969c4354f
commit e1473cde04
2 changed files with 4 additions and 4 deletions

View File

@@ -19,7 +19,7 @@ const Options = enum {
c,
// copy and paste this function into your user defined types to enable pretty printing for these types
pub fn format(value: @This(), comptime fmt: []const u8, options: std.fmt.FormatOptions, writer: anytype) anyerror!void {
pub fn format(value: @This(), comptime fmt: []const u8, options: std.fmt.FormatOptions, writer: anytype) !void {
try zlog.pretty_format(value, fmt, options, writer);
}
};
@@ -32,7 +32,7 @@ const Struct = struct {
e: Options = Options.b,
// same function as above...
pub fn format(value: @This(), comptime fmt: []const u8, options: std.fmt.FormatOptions, writer: anytype) anyerror!void {
pub fn format(value: @This(), comptime fmt: []const u8, options: std.fmt.FormatOptions, writer: anytype) !void {
try zlog.pretty_format(value, fmt, options, writer);
}
};

View File

@@ -9,7 +9,7 @@ const Options = enum {
c,
// copy and paste this function into your user defined types to enable pretty printing for these types
pub fn format(value: @This(), comptime fmt: []const u8, options: std.fmt.FormatOptions, writer: anytype) anyerror!void {
pub fn format(value: @This(), comptime fmt: []const u8, options: std.fmt.FormatOptions, writer: anytype) !void {
try zlog.pretty_format(value, fmt, options, writer);
}
};
@@ -22,7 +22,7 @@ const Struct = struct {
e: Options = Options.b,
// same function as above...
pub fn format(value: @This(), comptime fmt: []const u8, options: std.fmt.FormatOptions, writer: anytype) anyerror!void {
pub fn format(value: @This(), comptime fmt: []const u8, options: std.fmt.FormatOptions, writer: anytype) !void {
try zlog.pretty_format(value, fmt, options, writer);
}
};