Skip to content
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

Add first impl #4

Merged
merged 7 commits into from
Aug 6, 2016
Merged

Add first impl #4

merged 7 commits into from
Aug 6, 2016

Conversation

killercup
Copy link
Collaborator

Sorry, I couldn't stop myself! 😄

Best review by reading the commits one after another.

@colin-kiegel
Copy link
Owner

wow, that was fast - I will need some time for that. :-)

@killercup
Copy link
Collaborator Author

I think it makes sense to land a pretty basic version and add stuff one feature at a time. This has a few tests (but not nearly enough) and just implements setters.

I need to investigate how to best generate getter names. I really want this to generate idiomatic Rust, so getters names would be prefixed with get_, e.g. get_foo() and get_foo_bar().

If I read rust-lang/rust#29599 correctly, it's not possible to generate ident on stable. If we were to do getters on nightly only, interpolate_idents might be helpful (usage example).

A more creative solution for stable might be creating a single get(&self) -> new_sub_module::Getter method, where Getter is a newtype that implements methods to get each of the struct fields, so you can do x.get().foo().

@killercup
Copy link
Collaborator Author

Btw, feel free to enable travis and configure it some more (to render docs and stuff) – I just added a basic file so we don't forget about it :)

/// ## Gotchas
///
/// - Tuple structs and unit structs are not supported as they have no field
/// names.
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's ok for me. I think it's not worth the effort to try to support them - because some kind of implicit naming is needed after all. So let's just require explicitness here. :-)

@colin-kiegel
Copy link
Owner

looks awesome. :-)

@colin-kiegel
Copy link
Owner

PS: added travis.yml in master - please feel free to finetune it. I just copied a template from another project...

@killercup
Copy link
Collaborator Author

Let me just rebase this on master to make it mergeable again.

This can derive impls for setters. I think getters will be a bit
trickier since we have to concatenate `get_` and the field name. IIRC,
that is either impossible or really hard with `macro_rules!` macros.
@killercup killercup force-pushed the feature/first-impl branch from 5235801 to 42291d7 Compare August 6, 2016 21:15
@killercup
Copy link
Collaborator Author

I added TRAVIS_CARGO_NIGHTLY_FEATURE="", by the way, so this actually has a green build now :)

coveralls probably does not make sense for a macro crate.

I'm not sure. I might be clever enough to tell us that we are not testing all the code the macro is generating. Let's wait and see what it says.

@colin-kiegel colin-kiegel merged commit 0cba6c6 into master Aug 6, 2016
@colin-kiegel
Copy link
Owner

Yippieh :-)

Btw: Do you prefer a squashed merge or the usual one in these cases?

@colin-kiegel colin-kiegel deleted the feature/first-impl branch August 6, 2016 21:25
@killercup
Copy link
Collaborator Author

I prefer regular merges with all commits/history intact, since I try to build up features and it's nice to see how something was put together. When there are too many small fixes in response to feedback I'm cool with squashing those, though.

@killercup killercup mentioned this pull request Aug 6, 2016
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.

3 participants