Skip to content

Display imp for ClientIpSource - #38

Merged
imbolc merged 2 commits into
imbolc:mainfrom
calum4:main
Aug 29, 2025
Merged

Display imp for ClientIpSource#38
imbolc merged 2 commits into
imbolc:mainfrom
calum4:main

Conversation

@calum4

@calum4 calum4 commented Aug 29, 2025

Copy link
Copy Markdown
Contributor

Adds a Display impl for ClientIpSource, and a unit test to ensure that Display == FromStr.

Currently the test has to have the variants manually listed. I appreciate this is not ideal since new variants can be added to the enum and the test would still pass. Best alternative I can think of is to create a proc-macro which generates the test, something I didn't want to do without at least talking to you first.

My usecase should you be interested is declaring a default value for an arg with clap.

#[derive(Parser, Debug)]
pub(crate) struct Foo {
    #[arg(long, default_value_t = ClientIpSource::ConnectInfo)] // <------
    pub(crate) client_ip_source: ClientIpSource,
}

For some reason they appear to be using the ToString trait and then comparing the result of that rather than using FromStr.

Appreciate your work on this crate!

@imbolc
imbolc merged commit 6d970ed into imbolc:main Aug 29, 2025
7 checks passed
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.

2 participants