-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Open
Labels
A-deriveArea: #[derive]` macro APIArea: #[derive]` macro APIC-enhancementCategory: Raise on the bar on expectationsCategory: Raise on the bar on expectationsS-waiting-on-designStatus: Waiting on user-facing design to be resolved before implementingStatus: Waiting on user-facing design to be resolved before implementing
Description
Please complete the following tasks
- I have searched the discussions
- I have searched the open and rejected issues
Clap Version
4.0.29
Describe your use case
Currently, there's no way (that I can figure out) to set a default value on a PathBuf
using derive. You can see a minimal reproducible example here. The specific error is:
error[[E0277]](https://doc.rust-lang.org/stable/error-index.html#E0277): `PathBuf` doesn't implement `std::fmt::Display`
--> src/main.rs:6:24
|
6 | #[arg(short, long, default_value_t = PathBuf::from("/some/default/path"))]
| ^^^^^^^^^^^^^^^ `PathBuf` cannot be formatted with the default formatter; call `.display()` on it
|
= help: the trait `std::fmt::Display` is not implemented for `PathBuf`
= note: call `.display()` or `.to_string_lossy()` to safely print paths, as they may contain non-Unicode data
= note: required for `PathBuf` to implement `ToString`
Describe the solution you'd like
Ideally, either logic to allow for PathBufs to display correctly with the .display()
call, or a way of suplementing default values let you write a custom display string.
Alternatives, if applicable
No response
Additional Context
No response
jwodder and ncdnt
Metadata
Metadata
Assignees
Labels
A-deriveArea: #[derive]` macro APIArea: #[derive]` macro APIC-enhancementCategory: Raise on the bar on expectationsCategory: Raise on the bar on expectationsS-waiting-on-designStatus: Waiting on user-facing design to be resolved before implementingStatus: Waiting on user-facing design to be resolved before implementing