-
Notifications
You must be signed in to change notification settings - Fork 126
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
Implement display-bound attribute for derive-Display macro (#93) #97
Implement display-bound attribute for derive-Display macro (#93) #97
Conversation
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 squashed your other PR and merged in into master. Can you update this branch to use master as a base (git cherry-pick
should do it).
340e37a
to
c124e84
Compare
Done. |
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.
@ffuugoo at this point consider to work well on a code style of the implementation, until it growth too complex and messy for other contributors.
src/display.rs
Outdated
}, | ||
nested: inner_meta, | ||
.. | ||
}) => { |
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 guess this nested beast could be rewritten as we've discussed.
src/display.rs
Outdated
TraitBoundModifier, | ||
Type, | ||
TypeParamBound, | ||
TypePath, |
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.
Why import all this? Is using syn::Type
or syn::TypeParamBound
is too bad and requires syn::
part to be removed?
This has sense if there is a really long paths, to shorten it for better readability. The punctuated::Punctuated
is a good example. However, in much cases syn::Something
is quite good enough.
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.
Just followed existing style here. I'm for explicitly prefixing syn::
personally.
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.
@JelteF wouldn't you mind on some cosmetic refactoring for src/display.rs
file?
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.
Sounds good for the changes made here, but if it touches code in another part of the file let's do that in another PR.
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.
@ffuugoo ☝️
@@ -99,6 +114,50 @@ pub fn expand(input: &DeriveInput, trait_name: &str) -> Result<TokenStream> { | |||
}) | |||
} | |||
|
|||
fn trait_name_to_attribute_name(trait_name: &str) -> &'static str { |
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.
Consider to use smart well-known abbreviations, like attr
instead attribute
.
That's what you get when you use nightly by default. Should be fixed now. |
I think it's good now. It's still a draft PR. Is that on purpose? If no, I will merge this PR. |
Undrafted. (: |
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'd like to refactor it more deeply, but it's still relatively okay though.
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.
LGTM. If you feel like refactoring some more feel free to make a PR. For me the main important thing would be using early returns in the whole file more often. There is some very deeply nested code.
Second half of #93. This PR is based on top of #95.
Implemented
[display(bound = "...")]
attribute forDisplay
macro as proposed by @tyranron in #93.