Skip to content

feat: table widget uses "{f}" formatting of structs implementing a fo…#354

Merged
rockorager[bot] merged 2 commits into
rockorager:mainfrom
tabre:tabre
Jul 16, 2026
Merged

feat: table widget uses "{f}" formatting of structs implementing a fo…#354
rockorager[bot] merged 2 commits into
rockorager:mainfrom
tabre:tabre

Conversation

@tabre

@tabre tabre commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

Allowing the Table widget to use the format() method of a struct when it is available might be a cleaner option, in some cases, than manually converting to a string before inclusion in the Table data.

The following struct would be rendered as a standard IP v4 address (x.x.x.x) in the Table widget:

const Server = struct {
    addr: Io.net.Ip4Address,

    pub fn format(self: Server, writer: anytype) !void {
        try writer.print("{d}.{d}.{d}.{d}", .{
            self.addr.bytes[0],
            self.addr.bytes[1],
            self.addr.bytes[2],
            self.addr.bytes[3]
        });
    }
};

tabre and others added 2 commits July 16, 2026 10:05
Table cells can use a type's format() method with the {f} formatter, but optional payloads still fell back to {any} after unwrapping. This made optional custom values render differently from non-optional values.\n\nRoute both cases through a shared formatter and use it for optional payloads too. Add unit coverage for formatted table cell values without requiring terminal I/O.
@rockorager
rockorager Bot merged commit da6d9ea into rockorager:main Jul 16, 2026
4 checks passed
@rockorager

rockorager Bot commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

Thanks for the contribution! I added a small follow-up for optional values and merged it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant