Skip to content

SwitchSlot: remove Display implementation#10015

Merged
jgallagher merged 2 commits intomainfrom
john/switch-slot-no-display
Mar 12, 2026
Merged

SwitchSlot: remove Display implementation#10015
jgallagher merged 2 commits intomainfrom
john/switch-slot-no-display

Conversation

@jgallagher
Copy link
Copy Markdown
Contributor

Reasoning here is similar to #10010: this isn't really a naturally-displayable type, and in this case we were previously abusing this to stringify it both in the db (fixed by #9984) and the external API (fixed by #10014, on which this PR is based).

Maybe worth noting: I expected this to be entirely futureproofing, but by doing this I found a few external API types that I'd missed in an earlier draft of #10014 (types where we stringified SwitchSlots for output but never parsed them as input).

All our remaining uses of the display impl are either for logging or constructing internal error messages; I changed all of these to use Debug, and added a manual Debug implementation that matches the old Display implementation. This should keep the error messages and logs consistent while not leading us to the pit of sadness of assuming we can format and parse these values as strings without consideration.

Span::styled(port.to_string(), ok_style),
Span::styled(" on switch ", label_style),
Span::styled(switch.to_string(), ok_style),
Span::styled(switch_description, ok_style),
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be the only behavioral change; wicket will now display

* Port $NAME on switch 0

instead of

* Port $NAME on switch switch0

But if that feels like a regression I can change this back.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the new version is easier to read

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thoughts on * Port $NAME on switch0?

Copy link
Copy Markdown
Contributor Author

@jgallagher jgallagher Mar 10, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤷 I don't feel strongly about on switch 0 vs on switch0. Both are much nicer than on switch switch0. 😅

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh I flipped around the before and after haha -- this is great

Base automatically changed from john/switch-slot-enum-external-api to main March 12, 2026 15:36
@jgallagher jgallagher force-pushed the john/switch-slot-no-display branch from 1693aec to 6e4dd7c Compare March 12, 2026 15:41
@jgallagher jgallagher merged commit 6409f6a into main Mar 12, 2026
17 checks passed
@jgallagher jgallagher deleted the john/switch-slot-no-display branch March 12, 2026 17:45
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.

3 participants