Skip to content

feat: prefix a field with %% to use alternate Display #3258

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

michaelbeaumont
Copy link

@michaelbeaumont michaelbeaumont commented Apr 18, 2025

Motivation

Fixes #1311

There's currently no way to use {:#} to format a field, which is very important for anyhow::Error in particular.

Of course this should be backported v0.1

Solution

Add a new sigil %%. I had parsing issues with # so I quickly abandoned that, though there may be a way to make it work. I'm not attached to this particular sigil at all.

Add a new wrapper similar to DisplayValue that formats with the alternate # flag. The solution I have is use format_args!, this should be OK AFAICT. I think ideally we would use the Formatter API to just switch on alternate, but it's nightly only.

@michaelbeaumont michaelbeaumont force-pushed the feat/alternate-display-field branch from d849f38 to 5c6b8f3 Compare April 18, 2025 16:21
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.

Introduce a formatter sigil for "alternate" Display
1 participant