-
Notifications
You must be signed in to change notification settings - Fork 123
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
…142, #239) Resolves #142, #239 ## Synopsis This adds back support for top-level format strings of the Display derive. It now includes the display of the variant whenever the `_variant` placeholder appears be found. It also supports using the field. ## Solution This does not include the same support for Debug, since it is considered much less useful there and the differences between the Debug implementation and Display implementation make it a non-trivial port. Only named arguments are supported in the format string, no positional ones. This made the implementation easier, maybe in a future PR positional support can be added. This bumps MSRV to 1.70.0, on earlier versions the derived code throws the following error: ```rust error: there is no argument named `_0` --> tests/display.rs:1373:26 | 1373 | #[derive(Display)] | ^^^^^^^ | = note: did you intend to capture a variable `_0` from the surrounding scope? = note: to avoid ambiguity, `format_args!` cannot capture variables when the format string is expanded from a macro = note: this error originates in the derive macro `Display` (in Nightly builds, run with -Z macro-backtrace for more info) ``` Co-authored-by: Kai Ren <tyranron@gmail.com>
- Loading branch information
Showing
12 changed files
with
473 additions
and
97 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.