-
Notifications
You must be signed in to change notification settings - Fork 122
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
Fix incorrect fmt::Pointer
implementations attempt two
#381
Conversation
fmt::Pointer
implementations attempt two
efb2d7d
to
063426b
Compare
1d1d9fb
to
528cf06
Compare
0240938
to
1127455
Compare
679e0a4
to
6bfad73
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
6bfad73
to
c34b4ce
Compare
Rebased now, there's still a few more tests I want to add though. |
c34b4ce
to
539db9d
Compare
Okay it turned out that the tests I wanted to add already existed, so this is ready for review again. |
539db9d
to
774a4f2
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've extracted the similar code to the parent module and implemented the 2nd suggestion regarding expansion.
LGTM for me now, and I'm ready to merge. Feel free to leave any notices if you still have ones.
Resolves #381 (comment) ## Synopsis It has sense to bump MSRV to 1.75 for using RPITIT in implementations. ## Solution - [x] Bump up MSRV to 1.75. - [x] Switch to RPITIT in extension traits. - [x] Remove `cfg(msrv)`. ## Checklist - [x] Documentation is updated - [x] Tests are added/updated - [x] [CHANGELOG entry](/CHANGELOG.md) is added
Resolves JelteF/derive_more#381 (comment) ## Synopsis It has sense to bump MSRV to 1.75 for using RPITIT in implementations. ## Solution - [x] Bump up MSRV to 1.75. - [x] Switch to RPITIT in extension traits. - [x] Remove `cfg(msrv)`. ## Checklist - [x] Documentation is updated - [x] Tests are added/updated - [x] [CHANGELOG entry](/CHANGELOG.md) is added
Resolves #328
Requires #377
Requires #380
Synopsis
Debug
andDisplay
derives allow referring fields via short syntax (_0
for unnamed fields andname
for named fields):The way this works is by introducing a local binding in the macro expansion:
This, however, introduces double pointer indirection. For most of the
fmt
traits, this is totally OK. However, thefmt::Pointer
is sensitive to that:Solution
Pass all local bindings also as named parameters and dereference them there.
This allows
"{_0:p}"
to work as expected. Positional arguments and expressionsstill have the previous behaviour. This seems okay IMHO, as we can explain
that in expressions these local bindings are references and that you need
to dereference when needed, such as for
Pointer
.A downside of the current implementation is that users cannot use the names of our named parameters as names for their own named parameters, because we already use them. With some additional code this is fixable, but it doesn't seem important enough to fix. People can simply use a different name when creating their own named parameters, which is a good idea anyway because it will be less confusing to any reader of the code. If it turns out to be important to support this after all, we can still start to support it in a backwards compatible way (because now it causes a compilation failure).
Checklist